- Measure App Uninstalls
- User invite
- In-app purchase validation
- Android Out of Store
- Set plugin for IOS 14
You may update the uninstall token from the native side and from the plugin side, as shown in the methods below, you do not have to implement both of the methods, but only one. You can read more about iOS Uninstall Measurement in our knowledge base and you can follow our guide for Uninstall measurement on our DevHub.
You can register the uninstall token with AppsFlyer by modifying your AppDelegate.m
file, add the following function call with your uninstall token inside didRegisterForRemoteNotificationsWithDeviceToken.
Example:
@import AppsFlyerLib;
...
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// notify AppsFlyerLib
[[AppsFlyerLib shared] registerUninstall:deviceToken];
}
You can register the uninstall token with AppsFlyer by calling the following API with your uninstall token:
appsFlyerSdk.updateServerUninstallToken("token");
It is possible to utilize the Firebase Messaging Plugin for Flutter for everything related to the uninstall token. You can read more about Android Uninstall Measurement in our knowledge base and you can follow our guide for Uninstall measurement using FCM on our DevHub.
On the flutter side, you can register the uninstall token with AppsFlyer by calling the following API with your uninstall token:
appsFlyerSdk.updateServerUninstallToken("token");
A complete list of supported parameters is available here, you can also make use of the customParams
field to include custom parameters of your choice.
- First define the Onelink ID either in the AppsFlyerOptions, or in the setAppInviteOneLinkID API (find it in the AppsFlyer dashboard in the onelink section):
Future<void> setAppInviteOneLinkID(String oneLinkID, Function callback)
- Utilize the AppsFlyerInviteLinkParams class to set the query params in the user invite link:
class AppsFlyerInviteLinkParams {
final String channel;
final String campaign;
final String referrerName;
final String referreImageUrl;
final String customerID;
final String baseDeepLink;
final String brandDomain;
final Map<String?, String?>? customParams;
}
- Call the generateInviteLink API to generate the user invite link. Use the success and error callbacks for handling.
Full example:
// Setting the OneLinkID
appsFlyerSdk.setAppInviteOneLinkID('OnelinkID',
(res){
print("setAppInviteOneLinkID callback: $res");
});
// Creating the required parameters of the OneLink
AppsFlyerInviteLinkParams inviteLinkParams = new AppsFlyerInviteLinkParams(
channel: "",
referrerName: "",
baseDeepLink: "",
brandDomain: "",
customerID: "",
referreImageUrl: "",
campaign: "",
customParams: {"key":"value"}
);
// Generating the OneLink
appsFlyerSdk.generateInviteLink(inviteLinkParams,
(result){
print(result);
},
(error){
print(error);
}
);
Receipt validation is a secure mechanism whereby the payment platform (e.g. Apple or Google) validates that an in-app purchase indeed occurred as reported.
Learn more - https://support.appsflyer.com/hc/en-us/articles/207032106-Receipt-validation-for-in-app-purchases
There are two different functions, one for iOS and one for Android:
Android:
Future<dynamic> validateAndLogInAppAndroidPurchase(
String publicKey,
String signature,
String purchaseData,
String price,
String currency,
Map<String, String>? additionalParameters)
Example:
appsFlyerSdk.validateAndLogInAppAndroidPurchase(
"publicKey",
"signature",
"purchaseData",
"price",
"currency",
{"fs": "fs"});
iOS:
❗Important❗ for iOS - set SandBox to true
appsFlyer.useReceiptValidationSandbox(true);
Future<dynamic> validateAndLogInAppIosPurchase(
String productIdentifier,
String price,
String currency,
String transactionId,
Map<String, String> additionalParameters)
Example:
appsFlyerSdk.validateAndLogInAppIosPurchase(
"productIdentifier",
"price",
"currency",
"transactionId",
{"fs": "fs"});
Purchase validation callback:
void onPurchaseValidation(Function callback)
Example:
appsflyerSdk.onPurchaseValidation((res){
print("res: " + res.toString());
});
Please make sure to go over this guide to get a general understanding of how out of store attribution is set up in AppsFlyer, and how to implement it.
- Adding the conset dialog:
There are 2 ways to add it to your app:
a. Utilize the following Library: https://pub.dev/packages/app_tracking_transparency
Or
b. Add native implementation:
-
Add
#import <AppTrackingTransparency/AppTrackingTransparency.h>
in yourAppDelegate.m
-
Add the ATT pop-up for IDFA collection so your
AppDelegate.m
will look like this:
- (void)applicationDidBecomeActive:(nonnull UIApplication *)application {
if (@available(iOS 14, *)) {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
// native code here
}];
}
}
- Add Privacy - Tracking Usage Description inside your
.plist
file in Xcode.
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
- Optional: Set the
timeToWaitForATTUserAuthorization
property in theAppsFlyerOptions
to delay the sdk initazliation for a number ofx seconds
until the user accept the consent dialog:
AppsFlyerOptions options = AppsFlyerOptions(
afDevKey: DotEnv().env["DEV_KEY"],
appId: DotEnv().env["APP_ID"],
showDebug: true,
timeToWaitForATTUserAuthorization: 30
);
For more info visit our Full Support guide for iOS 14.