install_referrer
檢測您的應用程式是從哪裡安裝的(Google Play、App Store、TestFlight…)
檢測您的 Flutter 應用程式是從哪裡安裝的(Google Play、App Store、TestFlight…)
以下為英文專案原文快照,最新內容請造訪 GitHub。
A Flutter plugin that allows you to detect how your application was installed.
Feel free to open a PR to support new platforms.
install_referrer: ^1.2.1 to your pubspec.yaml file.import 'package:install_referrer/install_referrer.dart';Future InstallReferrer.referrer| 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.
| 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.
You can also get the package name (Android) or app id (iOS), by calling instead InstallReferrer.app
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
},
);
依賴清單 4 項
{"sdk":"flutter"}{"sdk":"flutter"}^1.0.0^2.0.2先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗