- initSdk
- startSDK
- onAppOpenAttribution
- onInstallConversionData
- onDeepLinking
- logEvent
- anonymizeUser
- setUserEmails
- setMinTimeBetweenSessions
- stop
- setCurrencyCode
- setIsUpdate
- enableUninstallTracking
- setImeiData
- setAndroidIdData
- enableLocationCollection
- setCustomerUserId
- setCustomerIdAndLogSession
- waitForCustomerUserId
- setAdditionalData
- setCollectAndroidId
- setCollectIMEI
- setHost
- getHostName
- getHostPrefix
- updateServerUninstallToken
- Validate Purchase
- validateAndLogInAppPurchaseV2
- sendPushNotificationData
- addPushNotificationDeepLinkPath
- User Invite
- enableFacebookDeferredApplinks
- enableTCFDataCollection
- setConsentData - [DEPRECATED]
- setConsentDataV2
- disableSKAdNetwork
- getAppsFlyerUID
- setCurrentDeviceLanguage
- setSharingFilterForPartners
- setOneLinkCustomDomain
- setDisableAdvertisingIdentifiers
- setPartnerData
- setResolveDeepLinkURLs
- setOutOfStore
- getOutOfStore
- setDisableNetworkData
- disableAppSetId
- performOnDeepLinking
- logAdRevenue - Since 6.15.1
| parameter | type | description |
|---|---|---|
appsFlyerOptions |
Map |
SDK configuration |
options
|
| Setting | Type | Description |
|---|---|---|
| devKey | String | Your application's devKey provided by AppsFlyer (required) |
| appId | String | Your application's App ID (required for iOS only) that you configured in your AppsFlyer dashboard |
| showDebug | bool | Debug mode - set to true for testing only, do not release to production with this parameter set to true! |
| timeToWaitForATTUserAuthorization | double | Delays the SDK start for x seconds until the user either accepts the consent dialog, declines it, or the timer runs out. |
| appInviteOneLink | String | The OneLink template ID that is used to generate a User Invite, this is not a required field in the AppsFlyerOptions, you may choose to set it later via the appropriate API. |
| disableAdvertisingIdentifier | bool | Opt-out of the collection of Advertising Identifiers, which include OAID, AAID, GAID and IDFA. |
| disableCollectASA | bool | Opt-out of the Apple Search Ads attributions. |
| manualStart | bool | Prevents from the SDK from sending the launch request after using appsFlyer.initSdk(...). When using this property, the apps needs to manually trigger the appsFlyer.startSdk() API to report the app launch. |
Example:
import 'package:appsflyer_sdk/appsflyer_sdk.dart';
//..
Map appsFlyerOptions = { "afDevKey": afDevKey,
"afAppId": appId,
"showDebug": true};
AppsflyerSdk appsflyerSdk = AppsflyerSdk(appsFlyerOptions);
Or you can use AppsFlyerOptions class instead
| parameter | type | description |
|---|---|---|
appsFlyerOptions |
AppsFlyerOptions |
SDK configuration |
Example:
import 'package:appsflyer_sdk/appsflyer_sdk.dart';
//..
final AppsFlyerOptions options = AppsFlyerOptions(afDevKey: "af dev key",
showDebug: true,
appId: "123456789");Once AppsflyerSdk object is created, you can call initSdk method.
| parameter | type | description |
|---|---|---|
monetizationNetwork |
String |
|
mediationNetwork |
String |
value must be taken from AFMediationNetwork |
currencyIso4217Code |
String |
|
revenue |
double |
|
additionalParameters |
Map<String, dynamic>? |
an enumeration that includes the supported mediation networks by AppsFlyer.
| networks |
|---|
| ironSource |
| applovinMax |
| googleAdMob |
| fyber |
| appodeal |
| admost |
| topon |
| tradplus |
| yandex |
| chartboost |
| unity |
| toponPte |
| customMediation |
| directMonetizationNetwork |
initSdk({bool registerConversionDataCallback, bool registerOnAppOpenAttributionCallback}) async (Changed in 1.2.2)
initialize the SDK, using the options initialized from the constructor|
Return response object with the field status
Example:
import 'package:appsflyer_sdk/appsflyer_sdk.dart';
//..
AppsflyerSdk _appsflyerSdk = AppsflyerSdk({...});
await _appsflyerSdk.initSdk(
registerConversionDataCallback: true,
registerOnAppOpenAttributionCallback: true,
registerOnDeepLinkingCallback: true)In version 6.13.0 of the appslfyer-flutter-plugin SDK we added the option of splitting between the initialization stage and start stage. All you need to do is add the property manualStart: true to the init object, and later call appsFlyer.startSdk() whenever you decide. If this property is set to false or doesn't exist, the sdk will start after calling appsFlyer.initSdk(...).
_appsflyerSdk.startSDK();- Trigger callback when onAppOpenAttribution is activated on the native side
Example:
_appsflyerSdk.onAppOpenAttribution((res) {
print("res: " + res.toString());
});- Trigger callback when onInstallConversionData is activated on the native side
Example:
_appsflyerSdk.onInstallConversionData((res) {
print("res: " + res.toString());
});- Trigger callback when onDeepLinking is activated on the native side
Example:
_appsflyerSdk.onDeepLinking((res) {
print("res: " + res.toString());
});- These in-app events help you to understand how loyal users discover your app, and attribute them to specific campaigns/media-sources. Please take the time define the event/s you want to measure to allow you to send ROI (Return on Investment) and LTV (Lifetime Value).
- The
logEventmethod allows you to send in-app events to AppsFlyer analytics. This method allows you to add events dynamically by adding them directly to the application code.
| parameter | type | description |
|---|---|---|
eventName |
String |
Use descriptive, action-based names (e.g., "purchase", "add_to_cart", "level_completed"), keep names concise but meaningful, use lowercase with underscores for consistency and avoid special characters and spaces. See the recommended event list by business. |
eventValues |
Map |
event details |
Example:
Future<bool?> logEvent(String eventName, Map? eventValues) async {
bool? result;
try {
result = await appsflyerSdk.logEvent(eventName, eventValues);
} on Exception catch (e) {}
print("Result logEvent: $result");
} anonymizeUser(shouldAnonymize)
It is possible to anonymize specific user identifiers within AppsFlyer analytics.
This complies with both the latest privacy requirements (GDPR, COPPA) and Facebook's data and privacy policies. To anonymize an app user.
| parameter | type | description |
|---|---|---|
| shouldAnonymize | boolean | True if want Anonymize user Data (default value is false). |
Example:
appsFlyerSdk.anonymizeUser(true); setUserEmails(List<String> emails, [EmailCryptType cryptType])
Set the user emails with the given encryption (EmailCryptTypeNone, EmailCryptTypeSHA256). the default encryption is EmailCryptTypeNone.
Example:
appsFlyerSdk.setUserEmails(
["a@a.com", "b@b.com"], EmailCryptType.EmailCryptTypeSHA256); void setMinTimeBetweenSessions(int seconds)
You can set the minimum time between session (the default is 5 seconds)
appsFlyerSdk.setMinTimeBetweenSessions(3) void stop(bool isStopped)
You can stop sending events to Appsflyer by using this method.
Example:
widget.appsFlyerSdk.stop(true); void setCurrencyCode(String currencyCode)
Example:
appsFlyerSdk.setCurrencyCode("currencyCode"); void setIsUpdate(bool isUpdate)
Example:
appsFlyerSdk.setIsUpdate(true); void enableUninstallTracking(String senderId)
Example:
appsFlyerSdk.enableUninstallTracking("senderId");Example:
appsFlyerSdk.setImeiData("imei"); void setAndroidIdData(String androidIdData)
Example:
appsFlyerSdk.setAndroidIdData("androidId"); void enableLocationCollection(bool flag)
Removed as of v6.8.0
Example:
appsFlyerSdk.enableLocationCollection(true); enableTCFDataCollection(bool shouldCollect)
The enableTCFDataCollection method is employed to control the automatic collection of the Transparency and Consent Framework (TCF) data. By setting this flag to true, the system is instructed to automatically collect TCF data. Conversely, setting it to false prevents such data collection.
Example:
appsFlyerSdk.enableTCFDataCollection(true); setConsentData(Map<String, Object> consentData) Deprecated
The AppsflyerConsent object helps manage user consent settings. By using the setConsentData we able to manually collect the TCF data. You can create an instance for users subject to GDPR or otherwise:
- Users subjected to GDPR:
var forGdpr = AppsFlyerConsent.forGDPRUser(
hasConsentForDataUsage: true,
hasConsentForAdsPersonalization: true
);
_appsflyerSdk.setConsentData(forGdpr);- Users not subject to GDPR:
var nonGdpr = AppsFlyerConsent.nonGDPRUser();
_appsflyerSdk.setConsentData(nonGdpr);The _appsflyerSdk handles consent data with setConsentData method, where you can pass the desired AppsflyerConsent instance.
To reflect TCF data in the conversion (first launch) payload, it's crucial to configure enableTCFDataCollection or setConsentData between the SDK initialization and start phase. Follow the example provided:
// Set AppsFlyerOption - make sure to set manualStart to true
final AppsFlyerOptions options = AppsFlyerOptions(
afDevKey: dotenv.env["DEV_KEY"]!,
appId: dotenv.env["APP_ID"]!,
showDebug: true,
timeToWaitForATTUserAuthorization: 15,
manualStart: true);
_appsflyerSdk = AppsflyerSdk(options);
// Init the AppsFlyer SDK
_appsflyerSdk.initSdk(
registerConversionDataCallback: true,
registerOnAppOpenAttributionCallback: true,
registerOnDeepLinkingCallback: true);
// Set configurations to the SDK
// Enable TCF Data Collection
_appsflyerSdk.enableTCFDataCollection(true);
// Set Consent Data
// If user is subject to GDPR
// var forGdpr = AppsFlyerConsent.forGDPRUser(hasConsentForDataUsage: true, hasConsentForAdsPersonalization: true);
// _appsflyerSdk.setConsentData(forGdpr);
// If user is not subject to GDPR
var nonGdpr = AppsFlyerConsent.nonGDPRUser();
_appsflyerSdk.setConsentData(nonGdpr);
// Here we start a session
_appsflyerSdk.startSDK(); Following this sequence ensures that the consent configurations take effect before the AppsFlyer SDK starts, providing accurate consent data in the first launch payload.
Note: You need to use either enableTCFDataCollection or setConsentData if you use both of them our backend will prioritize the provided consent data from setConsentData.
⚠️ This method replaces the deprecatedsetConsentData- for a complete guide, see our DMA compliance documentation.
Use this method to provide the user's consent settings to the AppsFlyer SDK. All parameters are optional - you only need to include the ones relevant to your use case.
Parameters:
| Parameter | Type | Description |
|---|---|---|
isUserSubjectToGDPR |
bool? |
Whether the user is subject to GDPR regulations |
consentForDataUsage |
bool? |
Whether the user consents to data usage by AppsFlyer |
consentForAdsPersonalization |
bool? |
Whether the user consents to personalized advertising |
hasConsentForAdStorage |
bool? |
Whether the user consents to ad storage |
📝 Note: Setting a parameter to
nullindicates the user hasn't explicitly provided consent for that option.
Example:
appsflyerSdk.setConsentDataV2(
isUserSubjectToGDPR: true,
consentForDataUsage: true,
consentForAdsPersonalization: false,
hasConsentForAdStorage: true,
); void setCustomerUserId(String userId)
Example:
appsFlyerSdk.setCustomerUserId("id"); void setCustomerIdAndLogSession(String userId) Android only!
Example:
appsFlyerSdk.setCustomerIdAndLogSession("id"); void waitForCustomerUserId(bool wait) Android only
You can set this function to true if you don't want to log events without setting customer id first.
Example:
appsFlyerSdk.waitForCustomerUserId(true);
appsFlyerSdk.setCustomerIdAndLogSession("id"); void setAdditionalData(Map additionalData)
Example:
var data = {"key1": "value1", "key2": "value2"};
appsFlyerSdk.setAdditionalData(data); void setCollectAndroidId(bool isCollect)
Example:
appsFlyerSdk.setCollectAndroidId(true); void setCollectIMEI(bool isCollect)
NOTE: Make sure to add <uses-permission android:name="android.permission.READ_PHONE_STATE" /> in the AndroidManifest and request these permissions in the runtime in order for the SDK to be able to collect IMEI
Example:
appsFlyerSdk.setCollectIMEI(false); void setHost(String hostPrefix, String hostName)
You can change the default host (appsflyer) by using this function
Example:
appsFlyerSdk.setHost("pref", "my-host");Example:
appsFlyerSdk.getHostName().then((name) {
print("Host name: ${name}");
}); Future<String> getHostPrefix()
Example:
appsFlyerSdk.getHostPrefix().then((name) {
print("Host prefix: ${name}");
}); void updateServerUninstallToken(String token)
Example:
appsFlyerSdk.updateServerUninstallToken("token");Cross-Platform V2 API (Recommended - BETA):
⚠️ BETA Feature: This API is currently in beta. While it's stable and recommended for new implementations, please test thoroughly in your environment before production use.
Future<Map<String, dynamic>> validateAndLogInAppPurchaseV2(AFPurchaseDetails purchaseDetails, {Map<String, String>? additionalParameters})
The new unified purchase validation API that works across both Android and iOS platforms. This is the recommended approach for validating in-app purchases.
| Parameter | Type | Description |
|---|---|---|
purchaseDetails |
AFPurchaseDetails |
Purchase details containing type, token, and product ID |
additionalParameters |
Map<String, String>? |
Optional additional parameters |
AFPurchaseDetails:
| Property | Type | Description |
|---|---|---|
purchaseType |
AFPurchaseType |
Type of purchase (oneTimePurchase or subscription) |
purchaseToken |
String |
Purchase token from the app store |
productId |
String |
Product identifier |
AFPurchaseType:
AFPurchaseType.oneTimePurchase- For one-time in-app purchasesAFPurchaseType.subscription- For subscription purchases
Example:
// Create purchase details
AFPurchaseDetails purchaseDetails = AFPurchaseDetails(
purchaseType: AFPurchaseType.oneTimePurchase,
purchaseToken: "your_purchase_token",
productId: "your_product_id",
);
// Validate purchase
try {
Map<String, dynamic> result = await appsFlyerSdk.validateAndLogInAppPurchaseV2(
purchaseDetails,
additionalParameters: {"custom_param": "value"}
);
print("Validation successful: $result");
} catch (e) {
print("Validation failed: $e");
}Legacy APIs:
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:
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 sandbox mode for iOS:
void useReceiptValidationSandbox(bool isSandboxEnabled)
Example:
appsFlyerSdk.useReceiptValidationSandbox(true);Purchase validation callback
void onPurchaseValidation(Function callback)
Example:
appsflyerSdk.onPurchaseValidation((res){
print("res: " + res.toString());
});
⚠️ BETA Feature: This API is currently in beta. While it's stable and recommended for new implementations, please test thoroughly in your environment before production use.
Future<Map<String, dynamic>> validateAndLogInAppPurchaseV2(AFPurchaseDetails purchaseDetails, {Map<String, String>? additionalParameters})
The unified cross-platform purchase validation API introduced in SDK v6.17.3. This is the recommended approach for validating in-app purchases as it provides a consistent interface across Android and iOS.
|| parameter | type | description |
|| --------- | ----- | ----------- |
|| purchaseDetails | AFPurchaseDetails | Purchase details object containing purchase type, token, and product ID |
|| additionalParameters | Map<String, String>? | Optional additional parameters to send with the validation request |
Returns: Future<Map<String, dynamic>> - Validation result with detailed response information
AFPurchaseDetails Properties:
|| property | type | description |
|| -------- | ----- | ----------- |
|| purchaseType | AFPurchaseType | Type of purchase (AFPurchaseType.oneTimePurchase or AFPurchaseType.subscription) |
|| purchaseToken | String | Purchase token obtained from the app store |
|| productId | String | Product identifier of the purchased item |
Example:
// Create purchase details
AFPurchaseDetails purchaseDetails = AFPurchaseDetails(
purchaseType: AFPurchaseType.subscription,
purchaseToken: "your_purchase_token_from_store",
productId: "premium_subscription_monthly",
);
// Validate the purchase
try {
Map<String, dynamic> validationResult = await appsflyerSdk.validateAndLogInAppPurchaseV2(
purchaseDetails,
additionalParameters: {
"app_version": "1.2.0",
"validation_source": "flutter_example"
}
);
print("✅ Purchase validation successful!");
print("Validation result: $validationResult");
} catch (e) {
print("❌ Purchase validation failed: $e");
// Handle validation error
}Key Benefits:
- Cross-platform compatibility: Works on both Android and iOS with the same API
- Type safety: Uses structured data classes instead of platform-specific parameters
- Enhanced error handling: Provides detailed error information in structured format
- Future-proof: Built on AppsFlyer's latest V2 validation infrastructure
- Automatic routing: Automatically routes to correct validation endpoints based on purchase type
Push-notification campaigns are used to create re-engagements with existing users → Learn more here
🟩 Android:
The AppsFlyer SDK requires a valid Activity context to process the push payload.
Do NOT call this method from the background isolate (e.g., _firebaseMessagingBackgroundHandler), as the activity is not yet created.
Instead, delay calling this method until the Flutter app is fully resumed and the activity is alive.
🍎 iOS:
This method can be safely called at any point during app launch or when receiving a push notification.
AppsFlyer supports two approaches for measuring push notification campaigns:
Use this approach when your push payload contains a custom af object with attribution parameters.
Required parameters: pid, is_retargeting, c
📦 Example Push Payload with af Object:
{
"af": {
"c": "test_campaign",
"is_retargeting": true,
"pid": "push_provider_int"
},
"aps": {
"alert": "Get 5000 Coins",
"badge": "37",
"sound": "default"
}
}Implementation (Android & iOS):
// 1️⃣ Handle Foreground Messages
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
appsFlyerSdk.sendPushNotificationData(message.data);
});
// 2️⃣ Handle Notification Taps (App in Background)
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
appsFlyerSdk.sendPushNotificationData(message.data);
});
// 3️⃣ Handle App Launch from Push (Terminated State)
// Store payload in background handler, then pass to AppsFlyer when app resumes
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setString('pending_af_push', jsonEncode(message.data));
}
// In your main() or splash screen after Flutter is initialized:
void handlePendingPush() async {
final prefs = await SharedPreferences.getInstance();
final json = prefs.getString('pending_af_push');
if (json != null) {
final payload = jsonDecode(json);
appsFlyerSdk.sendPushNotificationData(payload);
await prefs.remove('pending_af_push');
}
}Call handlePendingPush() during app startup (e.g., in your main() or inside your splash screen after ensuring Flutter is initialized).
Use this approach when your push payload contains a OneLink URL for deep linking. This method provides a unified deep linking experience.
⚠️ Important: This approach requires calling two different methods depending on the platform!
Call addPushNotificationDeepLinkPath BEFORE initializing the SDK to tell AppsFlyer where to find the OneLink URL in your push payload.
// Must be called BEFORE initSdk() or startSDK()
appsFlyerSdk.addPushNotificationDeepLinkPath(["deeply", "nested", "deep_link"]);
// Then initialize the SDK
await appsFlyerSdk.initSdk(
registerOnDeepLinkingCallback: true // Enable deep linking callback
);🟩 Android:
On Android, calling addPushNotificationDeepLinkPath is sufficient. The SDK automatically extracts and processes the OneLink URL.
🍎 iOS:
On iOS, you MUST also call sendPushNotificationData(userInfo) to pass the push payload to the SDK. The SDK then internally calls handlePushNotification to extract and process the OneLink URL.
📦 Example Push Payload with OneLink URL:
{
"deeply": {
"nested": {
"deep_link": "https://yourapp.onelink.me/ABC/campaign123"
}
},
"aps": {
"alert": "Check out our new feature!",
"badge": "1",
"sound": "default"
}
}Complete Implementation Example:
// ========================================
// 1. Configure SDK (in main.dart or app initialization)
// ========================================
void initializeAppsFlyer() async {
// STEP 1: Configure the deep link path BEFORE starting SDK
appsFlyerSdk.addPushNotificationDeepLinkPath(["deeply", "nested", "deep_link"]);
// STEP 2: Initialize SDK with deep linking callback
await appsFlyerSdk.initSdk(
registerOnDeepLinkingCallback: true
);
// STEP 3: Set up deep linking callback to handle the OneLink URL
appsFlyerSdk.onDeepLinking((DeepLinkResult result) {
if (result.status == Status.FOUND) {
print("Deep link found: ${result.deepLink?.deepLinkValue}");
// Handle deep link navigation here
}
});
}
// ========================================
// 2. Handle Push Notifications
// ========================================
// 🍎 iOS: MUST call sendPushNotificationData
// 🟩 Android: Optional (SDK auto-handles), but recommended for consistency
// 1️⃣ Foreground Messages
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
// iOS: Required to process OneLink URL
// Android: SDK processes automatically, but calling doesn't hurt
appsFlyerSdk.sendPushNotificationData(message.data);
});
// 2️⃣ Background Notification Taps (App in Background)
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
// iOS: Required to process OneLink URL
appsFlyerSdk.sendPushNotificationData(message.data);
});
// 3️⃣ App Launch from Push (Terminated State)
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setString('pending_af_push', jsonEncode(message.data));
}
// In main() or splash screen:
void handlePendingPush() async {
final prefs = await SharedPreferences.getInstance();
final json = prefs.getString('pending_af_push');
if (json != null) {
final payload = jsonDecode(json);
// iOS: Required to process OneLink URL from terminated state
appsFlyerSdk.sendPushNotificationData(payload);
await prefs.remove('pending_af_push');
}
}Traditional af Object |
OneLink URL (Recommended) | |
|---|---|---|
| Android | sendPushNotificationData(data) |
addPushNotificationDeepLinkPath() (auto-handles) |
| iOS | sendPushNotificationData(data) |
addPushNotificationDeepLinkPath() + sendPushNotificationData(data) |
| Deep Linking | Basic attribution only | Full deep linking with onDeepLinking callback |
| Use Case | Simple re-engagement | Re-engagement + in-app navigation |
- Traditional approach: Always call
sendPushNotificationData(payload)on both platforms - OneLink approach (Recommended):
- ✅ Both platforms: Call
addPushNotificationDeepLinkPath()before SDK init - ✅ iOS only: Also call
sendPushNotificationData(payload)when push is received - ✅ Both platforms: Handle deep links in
onDeepLinkingcallback
- ✅ Both platforms: Call
Registers a custom key path for resolving deep links inside custom JSON payloads in push notifications.
This is the recommended method of integrating AppsFlyer with push notifications. Learn more here.
⚠️ This method must be called BEFORE the AppsFlyer SDK is started — either before calling appsFlyerSdk.initSdk() (if using default auto-start), or before appsFlyerSdk.startSDK() (if using manual start mode).⚠️
Example:
appsFlyerSdk.addPushNotificationDeepLinkPath(["deeply", "nested", "deep_link"]);With this configuration, the SDK will extract the URL from the following push payload:
{
"deeply": {
"nested": {
"deep_link": "https://yourdeeplink2.onelink.me"
}
}
}- First define the Onelink ID (find it in the AppsFlyer dashboard in the onelink section:
Future<void> setAppInviteOneLinkID(String oneLinkID, Function callback)
- Set 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 referrerImageUrl;
final String customerID;
final String baseDeepLink;
final String brandDomain;
}- Call the generateInviteLink API to generate the user invite link. Use the success and error callbacks for handling.
void generateInviteLink(AppsFlyerInviteLinkParams parameters, Function success, Function error)
Example:
appsFlyerSdk.setAppInviteOneLinkID('OnelinkID',
(res){
print("setAppInviteOneLinkID callback: $res");
});
AppsFlyerInviteLinkParams inviteLinkParams = new AppsFlyerInviteLinkParams(
channel: "",
referrerName: "",
baseDeepLink: "",
brandDomain: "",
customerID: "",
referrerImageUrl: "",
campaign: "",
customParams: {"key":"value"}
);
appsFlyerSdk.generateInviteLink(inviteLinkParams,
(result){
print(result);
},
(error){
print(error);
}
); void enableFacebookDeferredApplinks(bool isEnabled)
Please make sure the relevant Facebook dependecies are added to the project!
For more information check the following article: https://support.appsflyer.com/hc/en-us/articles/207033826-Facebook-Ads-setup-guide#advanced-using-facebook-ads-appsflyer-sdks-for-deferred-deep-linking
Example:
appsFlyerSdk.enableFacebookDeferredApplinks(true); void disableSKAdNetwork(bool isEnabled)
Use this API in order to disable the SK Ad network (request will be sent but the rules won't be returned).
Example:
appsFlyerSdk.disableSKAdNetwork(true); Future<String?> getAppsFlyerUID() async
Use this API in order to get the AppsFlyer ID.
Example:
appsFlyerSdk.getAppsFlyerUID().then((AppsFlyerId) {
print("AppsFlyer ID: ${AppsFlyerId}");
}); void setCurrentDeviceLanguage(string language)
Use this API in order to set the language
Example:
appsFlyerSdk.setCurrentDeviceLanguage("en"); void setSharingFilterForPartners(List<String> partners)
setSharingFilter & setSharingFilterForAllPartners APIs were deprecated!
Use setSharingFilterForPartners instead.
Used by advertisers to exclude specified networks/integrated partners from getting data. Learn more here
Example:
appsFlyerSdk.setSharingFilterForPartners([]); // Reset list (default)
appsFlyerSdk.setSharingFilterForPartners(null); // Reset list (default)
appsFlyerSdk.setSharingFilterForPartners(['facebook_int']); // Single partner
appsFlyerSdk.setSharingFilterForPartners(['facebook_int', 'googleadwords_int']); // Multiple partners
appsFlyerSdk.setSharingFilterForPartners(['all']); // All partners
appsFlyerSdk.setSharingFilterForPartners(['googleadwords_int', 'all']); // All partners void setOneLinkCustomDomain(List<String> brandDomains)
Use this API in order to set branded domains.
Find more information in the following article on branded domains.
Example:
appsFlyerSdk.setOneLinkCustomDomain(["promotion.greatapp.com","click.greatapp.com","deals.greatapp.com"]); void setDisableAdvertisingIdentifiers(bool isSetDisableAdvertisingIdentifiersEnable)
Manually enable or disable Advertiser ID in Android & IDFA in iOS
Example:
appsFlyerSdk.setDisableAdvertisingIdentifiers(true); void setPartnerData(String partnerId, Map<String, Object> partnerData)
Allows sending custom data for partner integration purposes.
Example:
Map<String, Object> partnerData = {"puid": "1234", "puid": '5678'};
appsflyerSdk.setPartnerData("partnerId", partnerData); void setResolveDeepLinkURLs(List<String> urls)
Advertisers can wrap an AppsFlyer OneLink within another Universal Link. This Universal Link will invoke the app but any deep linking data will not propagate to AppsFlyer.
setResolveDeepLinkURLs enables you to configure the SDK to resolve the wrapped OneLink URLs, so that deep linking can occur correctly.
Example:
appsflyerSdk.setResolveDeepLinkURLs(["clickdomain.com", "myclickdomain.com", "anotherclickdomain.com"]); void setOutOfStore(String sourceName)
Android Only!
Specify the alternative app store that the app is downloaded from.
Example:
if(Platform.isAndroid){
appsflyerSdk.setOutOfStore("facebook_int");
} Future<String?> getOutOfStore()
Android Only!
Get the third-party app store referrer value.
Example:
if(Platform.isAndroid){
Future<String> store = appsflyerSdk.getOutOfStore();
store.then((store) {
print(store);
});
} void setDisableNetworkData(bool disable)
Android Only!
Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device.
Example:
if(Platform.isAndroid){
appsflyerSdk.setDisableNetworkData(true);
}Android Only!
Disables AppSet ID collection. Starting with v6.17.0, the SDK can automatically collect the AppSet ID. Use this method to opt-out of AppSet ID collection for privacy compliance.
Example:
if(Platform.isAndroid){
appsflyerSdk.disableAppSetId();
}Android Only!
Enables manual triggering of deep link resolution. This method allows apps that are delaying the call to appsflyerSdk.startSDK() to resolve deep links before the SDK starts.
Note:
This API will trigger the appsflyerSdk.onDeepLink callback. In the following example, we check if res.deepLinkStatus is equal to "FOUND" inside appsflyerSdk.onDeepLink callback to extract the deeplink parameters.
void afStart() async {
// SDK Options
final AppsFlyerOptions options = AppsFlyerOptions(
afDevKey: dotenv.env["DEV_KEY"]!,
appId: dotenv.env["APP_ID"]!,
showDebug: true,
timeToWaitForATTUserAuthorization: 15,
manualStart: true);
_appsflyerSdk = AppsflyerSdk(options);
// Init of AppsFlyer SDK
await _appsflyerSdk.initSdk(
registerConversionDataCallback: true,
registerOnAppOpenAttributionCallback: true,
registerOnDeepLinkingCallback: true);
// Conversion data callback
_appsflyerSdk.onInstallConversionData((res) {
print("onInstallConversionData res: " + res.toString());
setState(() {
_gcd = res;
});
});
// App open attribution callback
_appsflyerSdk.onAppOpenAttribution((res) {
print("onAppOpenAttribution res: " + res.toString());
setState(() {
_deepLinkData = res;
});
});
// Deep linking callback
_appsflyerSdk.onDeepLinking((DeepLinkResult dp) {
switch (dp.status) {
case Status.FOUND:
print(dp.deepLink?.toString());
print("deep link value: ${dp.deepLink?.deepLinkValue}");
break;
case Status.NOT_FOUND:
print("deep link not found");
break;
case Status.ERROR:
print("deep link error: ${dp.error}");
break;
case Status.PARSE_ERROR:
print("deep link status parsing error");
break;
}
print("onDeepLinking res: " + dp.toString());
setState(() {
_deepLinkData = dp.toJson();
});
});
if(Platform.isAndroid){
_appsflyerSdk.performOnDeepLinking();
}
_appsflyerSdk.startSDK();
}The logAdRevenue API is designed to simplify the process of logging ad revenue events to AppsFlyer from your Flutter application. This API tracks revenue generated from advertisements, enriching your monetization analytics. Below you will find instructions on how to use this API correctly, along with detailed descriptions and examples for various input scenarios.
To use the logAdRevenue method, you must:
- Prepare an instance of
AdRevenueDatawith the required information about the ad revenue event. - Call
logAdRevenuewith theAdRevenueDatainstance.
AdRevenueData Class AdRevenueData is a data class representing all the relevant information about an ad revenue event:
monetizationNetwork: The source network from which the revenue was generated (e.g., AdMob, Unity Ads).mediationNetwork: The mediation platform managing the ad (use AFMediationNetwork enum for supported networks).currencyIso4217Code: The ISO 4217 currency code representing the currency of the revenue amount (e.g., "USD", "EUR").revenue: The amount of revenue generated from the ad.additionalParameters: Additional parameters related to the ad revenue event (optional).
AFMediationNetwork Enum AFMediationNetwork is an enumeration that includes the supported mediation networks by AppsFlyer. It's important to use this enum to ensure you provide a valid network identifier to the logAdRevenue API.
// Instantiate AdRevenueData with the ad revenue details.
AdRevenueData adRevenueData = AdRevenueData(
monetizationNetwork: "GoogleAdMob", // Replace with your actual monetization network.
mediationNetwork: AFMediationNetwork.applovinMax.value, // Use the value from the enum.
currencyIso4217Code: "USD",
revenue: 1.23,
additionalParameters: {
// Optional additional parameters can be added here. This is an example, can be discard if not needed.
'adUnitId': 'ca-app-pub-XXXX/YYYY',
'ad_network_click_id': '12345'
}
);
// Log the ad revenue event.
logAdRevenue(adRevenueData);Additional Points
- Mediation network input must be from the provided AFMediationNetwork
enum to ensure proper processing by AppsFlyer. For instance, use
AFMediationNetwork.googleAdMob.valueto denote Google AdMob as the Mediation Network. - The
additionalParametersmap is optional. Use it to pass any extra information you have regarding the ad revenue event; this information could be useful for more refined analytics. - Make sure the
currencyIso4217Codeadheres to the appropriate standard. Misconfigured currency code may result in incorrect revenue tracking.
