FLUTTER ECOSYSTEM

g123k/flutter_plugin_install_referrer

检测您的 Flutter 应用程序是从何处安装的(Google Play、App Store、TestFlight 等)

flutter_plugin_install_referrer 项目封面
Stars
23
Forks
29
最近推送(UTC)
2024年7月12日
项目状态
已归档
Edouard Marquez GitHub avatar
GITHUB User

Edouard Marquez ↗

Android & Flutter developer

Paris, France官方网站 ↗
语言DartJavaObjective-CKotlinRubySwiftShell

技术话题

此仓库发布的插件

使用的依赖

依赖清单 4 项
  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_lints开发依赖^1.0.0
  • pigeon开发依赖^2.0.2

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

install_referrer

Pub

A Flutter plugin that allows you to detect how your application was installed.

Supported platforms

  • Android: ✅
  • iOS: ✅

Feel free to open a PR to support new platforms.

Installation

  1. Add install_referrer: ^1.2.1 to your pubspec.yaml file.
  2. Import import 'package:install_referrer/install_referrer.dart';
  3. Get the value by invoking the Future InstallReferrer.referrer

Possibles values

Android
Store Value
Google Play InstallationAppReferrer.androidGooglePlay
Amazon App Store InstallationAppReferrer.androidAmazonAppStore
Huawei App Gallery InstallationAppReferrer.androidHuaweiAppGallery
Oppo App Market InstallationAppReferrer.androidOppoAppMarket
Samsung App Shop InstallationAppReferrer.androidSamsungAppShop
Vivo App Store InstallationAppReferrer.androidVivoAppStore
Xiaomi App Store InstallationAppReferrer.androidXiaomiAppStore
Others InstallationAppReferrer.androidManually

If the application was installed from a third party app (eg: GMail, Google Drive, Chrome…), it will be considered as a manual installation (InstallationAppReferrer.androidManually).

If the application was installed from a store (FDroid, Amazon App Shop…) which was not preinstalled on the device (a "non-system" app), it will also be considered as a manual installation (InstallationAppReferrer.androidManually).

If the Android application is in debug mode, it will be marked as InstallationAppReferrer.androidDebug.

iOS
Store Value
App Store InstallationAppReferrer.iosAppStore
Test Flight InstallationAppReferrer.iosTestFlight

If the iOS application is in debug mode (eg: from the simulator), it will be marked as InstallationAppReferrer.iosDebug.

Package name

You can also get the package name (Android) or app id (iOS), by calling instead InstallReferrer.app

Widgets

If you want to receive the result directly in a Widget, you have two choices: InstallReferrerDetectorListener and InstallReferrerDetectorBuilder :

InstallReferrerDetectorBuilder(
  builder: (BuildContext context, InstallationApp? app) {
    if (app == null) {
      return const CircularProgressIndicator.adaptive();
    } else {
      return Text(
        'Package name:\n${app.packageName ?? 'Unknown'}\n'
        'Referrer:\n${referrerToReadableString(app.referrer)}',
          textAlign: TextAlign.center,
      );
    }
  },
);
InstallReferrerDetectorListener(
  child: YourWidget(),
    onReferrerAvailable: (InstallationApp? app) {
      // TODO
    },
);