AppsFlyerLib
Overview
AppsFlyerLib
is the main class of the AppsFlyer Android SDK, and encapsulates most of the methods.
Go back to the SDK reference index.
Import the library
import com.appsflyer.AppsFlyerLib;
Access the SDK instance
Access the SDK singleton instance:
AppsFlyerLib appsflyer = AppsFlyerLib.getInstance();
Methods
addPushNotificationDeepLinkPath
Method signature
void addPushNotificationDeepLinkPath(java.lang.String... deepLinkPath)
Description
Configures how the SDK extracts deep link values from push notification payloads.
Input arguments
Type | Name | Description |
---|---|---|
String... | deepLinkPath | An array of String s that corresponds to the JSON path of the deep link. |
Returns
void
.
Usage example
Basic configuration:
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("af_push_link");
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("af_push_link")
Advanced configuration:
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link");
AppsFlyerLib.getInstance().addPushNotificationDeepLinkPath("deeply", "nested", "deep_link")
This call matches the following payload structure:
{
"deeply": {
"nested": {
"deep_link": "https://yourdeeplink2.onelink.me"
}
}
}
anonymizeUser
Method signature
void anonymizeUser(boolean shouldAnonymize)
Description
Anonymize a user's installs, events, and sessions.
Input arguments
Type | Name | Description |
---|---|---|
boolean | shouldAnonymize | Defaults to false . |
Returns
void
Usage example
AppsFlyerLib.getInstance().anonymizeUser(true);
AppsFlyerLib.getInstance().anonymizeUser(true)
appendParametersToDeepLinkingURL
Method signature
void appendParametersToDeepLinkingURL(java.lang.String contains,
java.util.Map<java.lang.String,java.lang.String> parameters)
Description
Enables app owners using App Links for deep linking (without OneLink) to attribute sessions initiated via a domain associated with their app.
Call this method before calling
start
You must provide the following parameters in the parameters
Map
:
pid
is_retargeting
must be set totrue
Input arguments
Type | Name | Description |
---|---|---|
String | contains | A string contained in the deep link URL |
Map<String, String> | parameters | Attribution parameters to be appended to the matched URLs |
Returns
void
Usage example
HashMap<String, String> urlParameters = new HashMap<>();
urlParameters.put("pid", "exampleDomain"); // Required
urlParameters.put("is_retargeting", "true"); // Required
AppsFlyerLib.getInstance().appendParametersToDeepLinkingURL("example.com", urlParameters);
AppsFlyerLib.getInstance().appendParametersToDeepLinkingURL("example.com",
mapOf("pid" to "exampleDomain", "is_retargeting" to "true")) // Required
In the example above, the resulting attribution URL sent to AppsFlyer servers is:
example.com?pid=exampleDomain&is_retargeting=true
enableFacebookDeferredApplinks
Method signature
void enableFacebookDeferredApplinks(boolean isEnabled)
Description
Enable the collection of Facebook Deferred AppLinks. Requires Facebook SDK and Facebook app on target/client device.
This API must be invoked before initializing the AppsFlyer SDK in order to function properly.
Input arguments
Type | Name | Description |
---|---|---|
boolean | isEnabled | Should Facebook's deferred app links be processed by the AppsFlyer SDK. |
Returns
void
enableLocationCollection
Removed in V6.8.0
Method signature
AppsFlyerLib enableLocationCollection(boolean flag)
Description
Enable the AppsFlyer SDK to collect the last known location. Requires ACCESS_COARSE_LOCATION
and ACCESS_FINE_LOCATION
Manifest permissions.
Input arguments
Type | Name | Description |
---|---|---|
boolean | flag |
Returns
void
enableTCFDataCollection
Method signature
AppsFlyerLib enableTCFDataCollection (boolean flag)
Description
Enables the collection of Transparency and Consent Framework (TCF) data from SharedPreferences
. The data was placed in SharedPreferences
by the device TCF v2.2 compatible Consent Management Platform (CMP).
Input arguments
Type | Name | Description |
---|---|---|
boolean | flag | A boolean value to enable (true ) or disable (false ) the collection of TCF data. The SDK collects TCF data when the flag is set to true . |
Returns
void
getAppsFlyerUID
Method signature
java.lang.String getAppsFlyerUID(Context context)
Description
Get AppsFlyer's unique device ID. The SDK generates an AppsFlyer unique device ID upon app installation. When the SDK is started, this ID is recorded as the ID of the first app install.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
Returns
AppsFlyer's unique device ID.
Usage example
String appsFlyerId = AppsFlyerLib.getInstance().getAppsFlyerUID(this);
String appsFlyerId = AppsFlyerLib.getInstance().getAppsFlyerUID(this)
getAttributionId
Method signature
java.lang.String getAttributionId(Context context)
Description
Get the Facebook attribution ID, if one exists.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
Returns
void
Usage example
String attributionId = AppsFlyerLib.getInstance().getAttributionId(this);
String attributionId = AppsFlyerLib.getInstance().getAttributionId(this)
getHostName
Method signature
java.lang.String getHostName()
Description
Get the host name.
Default value is "appsflyer.com"
Input arguments
This function takes no parameters.
Returns
Type | Description |
---|---|
String | Currently set hostname. |
Usage example
getHostPrefix
Method signature
java.lang.String getHostPrefix()
Description
Get the custom set host prefix.
Input arguments
This function takes no parameters.
Returns
Host prefix.
getInstance
Method signature
AppsFlyerLib getInstance()
Description
Returns the SDK instance, through which you can access the methods described in this document.
Input arguments
This function takes no parameters.
Returns
AppsFlyerLib singleton instance.
getOutOfStore
Method signature
java.lang.String getOutOfStore(Context context)
Description
Get the third-party app store referrer value.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
Returns
AF_Store
value.
getSdkVersion
Method signature
java.lang.String getSdkVersion()
Description
Get the AppsFlyer SDK version used in app.
Input arguments
This function takes no parameters.
Returns
AppsFlyer SDK version.
init
Method signature
AppsFlyerLib init(java.lang.String key,
AppsFlyerConversionListener conversionDataListener,
Context context)
Description
Use this method to initialize AppsFlyer SDK. This API should be called inside the Application's onCreate
method.
Input arguments
Type | Name | Description |
---|---|---|
String | key | AppsFlyer dev key |
AppsFlyerConversionDataListener | conversionDataListener | (Optional) implement the AppsFlyerConversionDataListener to access AppsFlyer's conversion data. Can be null. |
Context | context | Application Context. |
Returns
void
Usage example
See initializing the SDK.
isPreInstalledApp
Method signature
boolean isPreInstalledApp(Context context)
Description
Boolean indicator for preinstall by Manufacturer.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
Returns
boolean
.
Usage example
isStopped
Method signature
boolean isStopped()
Description
Check if the SDK was stopped.
Input arguments
This function takes no parameters.
Returns
Type | Description |
---|---|
boolean | true if stopped, false otherwise. |
Usage example
logAdRevenue
Added in v6.15.0
Method signature
public abstract void logAdRevenue(
@NonNull AFAdRevenueData adRevenueData,
@Nullable Map<String, Object> additionalParameters
);
Description
The method sends an ad revenue event to AppsFlyer. See more information in Ad revenue.
Input parameters
Name | Type | Description |
---|---|---|
adRevenueData | AFAdRevenueData | An object that encapsulates all the mandatory parameters of the adRevenue event. The object is passed to the logAdRevenue method. |
additionalParameters | Map<String, Object> | An optional dictionary containing additional parameters to log with the adRevenue event. |
Returns
void
.
AFAdRevenueData
An object that encapsulates all mandatory adRevenue
data received from the mediation network.
Definition
data class AFAdRevenueData(
val monetizationNetwork: String,
val mediationNetwork: MediationNetwork,
val currencyIso4217Code: String,
val revenue: Double
)
AFAdRevenueData parameters
Name | Type | Description |
---|---|---|
monetizationNetwork | String | The monetization network name. |
mediationNetwork | MediationNetwork | The mediation network enum. |
currencyIso4217Code | String | The ad revenue event currency is a String validated against currencyIso4217Code |
revenue | Double | The ad revenue event amount. |
MediationNetwork
Name | Type | Comments |
---|---|---|
ironsource | String | |
applovinmax | String | |
googleadmob | String | |
fyber | String | |
appodeal | String | |
admost | String | |
topon | String | |
tradplus | String | |
yandex | String | |
chartboost | String | |
unity | String | |
customMediation | String | The mediation solution is not on the list of supported mediation partners. |
directMonetizationNetwork | String | The app integrates directly with monetization networks without mediation. |
logEvent
Method signature
void logEvent(Context context,
java.lang.String eventName,
java.util.Map<java.lang.String,java.lang.Object> eventValues)
Description
Log an in-app event.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context |
String | eventName | Event name |
Map | eventValues | Event values |
Returns
void
Usage example
logEvent
Method signature
void logEvent(Context context,
java.lang.String eventName,
java.util.Map<java.lang.String,java.lang.Object> eventValues,
AppsFlyerRequestListener listener)
Description
Same as logEvent, with AppsFlyerRequestListener. HttpURLConnection.HTTP_OK
from
server will invoke the AppsFlyerRequestListener#onSuccess()
method. AppsFlyerRequestListener#onError(int, String) will return
the error in case one occurs
Input arguments
This function takes no parameters.
Returns
void
Usage example
logLocation
Method signature
void logLocation(Context context,
double latitude,
double longitude)
Description
Manually log the location of the user.
This method creates an af_location_coordinates
in-app event, with the af_lat
and af_long
event parameters.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context |
double | latitude | Latitude |
double | longitude | Longitude |
Returns
void
Usage example
logSession
Method signature
void logSession(Context ctx)
Description
If your app is a background utility app, you can use this API in your Activity’s onCreate() to manually log and send a session.
Input arguments
Type | Name | Description |
---|---|---|
Context | ctx | Application / Activity context |
Usage example
public void logSession(Context context);
public void logSession(Context context)
Returns
void
onPause
Method signature
void onPause(Context context)
Description
For Cocos2dx platform only
Cocos2dx has his own applicationDidEnterBackground event.
Therefore 'onPause' will be called from C++ by JNI
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context |
Returns
void
Usage example
performOnAppAttribution
Deprecated since V6.3.2
Method signature
void performOnAppAttribution(Context context,
java.net.URI link)
Description
Used to manually resolve deep links.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context |
java.net.URI | link | Link to resolve |
Returns
void
Usage example
AppsFlyerLib.getInstance().performOnAppAttribution(context, uri);
AppsFlyerLib.getInstance().performOnAppAttribution(context, uri)
performOnDeepLinking
Added in V6.3.1+
Method signature
public void performOnDeepLinking(@NonNull Intent intent, @NonNull Context context);
Description
Enables manual triggering of deep link resolution. This method allows apps that are delaying the call to start to resolve deep links before the SDK starts.
- If a
DeepLinkListener
is registered, supports both deferred and direct deep linking - If a
AppsFlyerConversionListener
is registered, only supports direct deep linking
It's recommended to call this from an Activity
's onResume
, for activities that can be launched via deep linking.
Note: Direct deep links processed by this API will not be reported to the server.
Usage example
@Override
protected void onResume() {
super.onResume();
AppsFlyerLib appsflyer = AppsFlyerLib.getInstance();
appsflyer.performOnDeepLinking(getIntent(),this);
}
Input arguments
Type | Name | Description |
---|---|---|
Intent | intent | |
Context | context | Application / Activity context. |
Returns
void
registerConversionListener
Method signature
void registerConversionListener(Context context,
AppsFlyerConversionListener conversionDataListener)
Description
Register a conversion data listener. You can also use init
to register the listener.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
AppsFlyerConversionListener | conversionDataListener | The AppsFlyerConversionListener object to register. |
Returns
void
Usage example
// conversionDataListener is an object of type AppsFlyerConversionListener.
AppsFlyerLib.getInstance().registerConversionListener(getApplicationContext(), conversionDataListener);
// conversionDataListener is an object of type AppsFlyerConversionListener.
AppsFlyerLib.getInstance().registerConversionListener(getApplicationContext(), conversionDataListener)
Here's an example implementation of AppsFlyerConversionListener
.
registerValidatorListener (LEGACY)
Method signature
void registerValidatorListener(Context context,
AppsFlyerInAppPurchaseValidatorListener validationListener)
Description
Register a validation listener for the validateAndLogInAppPurchase
API.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
AppsFlyerInAppPurchaseValidatorListener | validationListener | The AppsFlyerInAppPurchaseValidatorListener object to register. |
Returns
void
Usage example
sendAdRevenue (LEGACY)
Deprecated in v6.15.0
(Supported until SDK v6.14.2 For versions including and above v6.15.0 use logAdRevenue
)
Method signature
void sendAdRevenue(Context context,
java.util.Map<java.lang.String,java.lang.Object> eventValues)
Description
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
Map<String, Object> | validationListener |
Returns
void
sendPushNotificationData
Method signature
void sendPushNotificationData(Activity activity)
Description
Measure and get data from push-notification campaigns. Call this method inside the onCreate
method of Activity
s that are launched from push notifications.
Input arguments
Type | Name | Description |
---|---|---|
Activity | activity | The Activity which is launched via the notification. |
Returns
void
.
Usage example
setAdditionalData
Calling
setAddiotionalData
before first launch will have the additional data included in installs, sessions, as well as in-app events.
Method signature
void setAdditionalData(java.util.Map<java.lang.String,java.lang.Object> customData)
Description
Use to add custom data to events' payload. It will appear in raw-data reports.
Input arguments
Type | Name | Description |
---|---|---|
HashMap | customData |
Returns
void
.
setAndroidIdData
Method signature
void setAndroidIdData(java.lang.String aAndroidId)
Description
By default, IMEI and Android ID are not collected by the SDK if the Android version is higher than KitKat (4.4) and the device contains Google Play Services. Use this API to explicitly send Android ID to AppsFlyer.
Input arguments
Type | Name | Description |
---|---|---|
String | aAndroidId | Android device ID. |
Returns
void
setAppId
Method signature
void setAppId(java.lang.String id)
Description
Input arguments
Type | Name | Description |
---|---|---|
String | id | Android App ID. |
Returns
void
setAppInviteOneLink
Method signature
void setAppInviteOneLink(java.lang.String oneLinkId)
Description
Set the OneLink ID that should be used for attributing user-Invite. The link that is generated for the user invite will use this OneLink as the base link. See setting OneLink for user-invite attribution.
Input arguments
Type | Name | Description |
---|---|---|
String | oneLinkId | OneLink ID obtained from the AppsFlyer Dashboard. |
Returns
void
.
setCollectAndroidID
Method signature
void setCollectAndroidID(boolean isCollect)
Description
Opt-in to Android ID collection. Forces the SDK to collect Android ID.
Input arguments
Type | Name | Description |
---|---|---|
boolean | isCollect | Set to true to opt-in. |
Returns
void
.
setCollectIMEI
Method signature
void setCollectIMEI(boolean isCollect)
Description
Opt-in to IMEI collection. Forces the SDK to collect IMEI.
Input arguments
Type | Name | Description |
---|---|---|
boolean | isCollect | Set to true to opt-in. |
Returns
void
.
setCollectOaid
Method signature
void setCollectOaid(boolean isCollect)
Description
Opt-in/opt-out of OAID collection. By default, the SDK tries to collect OAID.
Input arguments
Type | Name | Description |
---|---|---|
boolean | isCollect | Defaults to true . Set to false to opt-out. |
Returns
void
.
setConsentData
Method signature
AppsFlyerLib.getInstance().setConsentData(AppsFlyerConsent afConsent)
Description
Transfers consent data to the SDK.
Input arguments
Type | Name | Description |
---|---|---|
AppsFlyerConsent | afConsent | An object containing user consent data |
setCurrencyCode
Method signature
void setCurrencyCode(java.lang.String currencyCode)
Description
Sets the currency for in-app purchases. The currency code should be a 3 character ISO 4217 code.
Input arguments
Type | Name | Description |
---|---|---|
String | currencyCode | 3 character ISO 4217 code. Defaults to "USD" . |
Returns
void
.
setCustomerIdAndLogSession
Before calling this method, the method
waitForCustomerUserId
must be called
Method signature
void setCustomerIdAndLogSession(java.lang.String id,
Context context)
Description
Use to set customer user id and starts the SDK.
Input arguments
Type | Name | Description |
---|---|---|
String | id | Customer ID for client. |
String | context | Application / Activity context. |
Returns
void
setCustomerUserId
Method signature
void setCustomerUserId(java.lang.String id)
Description
Setting your own customer ID enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and other devices’ IDs.
This ID is available in raw-data reports and in the Postback APIs for cross-referencing with your internal IDs.
Input arguments
Type | Name | Description |
---|---|---|
String | id | Customer ID for client. |
Returns
void
.
setDebugLog
Method signature
void setDebugLog(boolean shouldEnable)
Description
Enables Debug logs for the AppsFlyer SDK. Should only be set to true in development environments.
Input arguments
Type | Name | Description |
---|---|---|
boolean | shouldEnable | Defaults to false . |
Returns
void
.
Usage example
setDisableAdvertisingIdentifiers
Added in V6.3.2
Method signature
void setDisableAdvertisingIdentifiers(boolean disable);
Description
Disables collection of various Advertising IDs by the SDK. This includes Google Advertising ID (GAID), OAID and Amazon Advertising ID (AAID).
Input arguments
Type | Name | Description |
---|---|---|
boolean | disable | Defaults to false . |
Returns
void
.
setDisableNetworkData
Added in V6.7.0
Method signature
void setDisableNetworkData(boolean disable);
Description
Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device.
Input arguments
Type | Name | Description |
---|---|---|
boolean | disable | Defaults to false . |
Returns
void
.
setExtension
Method signature
void setExtension(java.lang.String extension)
Description
SDK plugins and extensions will set this field.
Input arguments
Type | Name | Description |
---|---|---|
String | extension | Extension name. |
Returns
void
.
setHost
Method signature
void setHost(java.lang.String hostPrefixName,
java.lang.String hostName)
Description
Set a custom host. Note: Starting SDK V6.10, if the host is sent with an empty or null value, the API call is ignored.
Input arguments
Type | Name | Description |
---|---|---|
String | hostPrefixName | Host prefix. |
String | hostName | Host name. |
Returns
void
.
setImeiData
Method signature
void setImeiData(java.lang.String aImei)
Description
By default, IMEI and Android ID are not collected by the SDK if the OS version is higher than KitKat (4.4) and the device contains Google Play Services.
Input arguments
Type | Name | Description |
---|---|---|
String | aImei | Device IMEI. |
Returns
void
.
setIsUpdate
Method signature
void setIsUpdate(boolean isUpdate)
Description
Manually set that the application was updated.
Input arguments
Type | Name | Description |
---|---|---|
boolean | isUpdate |
Returns
void
.
setLogLevel
Method signature
void setLogLevel(AFLogger.LogLevel logLevel)
Description
Set the SDK log level.
Input arguments
Type | Name | Description |
---|---|---|
String | logLevel | Log level. |
Returns
void
.
setMinTimeBetweenSessions
Method signature
void setMinTimeBetweenSessions(int seconds)
Description
Set a custom value for the minimum required time between sessions.
Input arguments
Type | Name | Description |
---|---|---|
int | seconds | Sets the minimum time that must pass between two app launches to count as two separate sessions. If not set, the default minimum time between sessions is 5 seconds. |
Returns
void
.
setOaidData
Method signature
void setOaidData(java.lang.String oaid)
Description
By default, OAID is not collected by the SDK. Use this API to explicitly send OAID to AppsFlyer.
Input arguments
Type | Name | Description |
---|---|---|
String | oaid | Device OAID. |
Returns
void
.
setOneLinkCustomDomain
Method signature
void setOneLinkCustomDomain(java.lang.String... domains)
Description
In order for AppsFlyer SDK to successfully resolve hidden (decoded in shortlink ID) attribution parameters, any domain that is configured as a branded domain in the AppsFlyer Dashboard should be provided to this method.
Input arguments
Type | Name | Description |
---|---|---|
String... | domains | Array of domains that the SDK should treat as branded domains (the SDK will try to resolve them as OneLinks). |
Returns
void
.
setOutOfStore
Method signature
void setOutOfStore(java.lang.String sourceName)
Description
Specify the alternative app store that the app is downloaded from.
Input arguments
Type | Name | Description |
---|---|---|
String | sourceName | Third-party app store name. |
Returns
void
.
Usage example
AppsFlyerLib.getInstance().setOutOfStore("baidu");
AppsFlyerLib.getInstance().setOutOfStore("baidu")
setPartnerData
Method signature
void setPartnerData(@NonNull String partnerId, Map<String, Object> data);
Description
Allows sending custom data for partner integration purposes.
Input arguments
Type | Name | Description |
---|---|---|
String | partnerId | ID of the partner (usually suffixed with "_int"). |
Map | data | Customer data, depends on the integration configuration with the specific partner. |
Returns
void
.
Usage example
Map<String, Object> partnerData = new HashMap();
partnerData.put("puid", "123456789");
AppsFlyerLib.getInstance().setPartnerData("test_int", partnerData);
val partnerData = mapOf("puid" to "123456789")
AppsFlyerLib.getInstance().setPartnerData("test_int", partnerData)
setPhoneNumber
Method signature
void setPhoneNumber(java.lang.String phoneNumber)
Description
Will be sent as an SHA-256 encrypted string.
Input arguments
Type | Name | Description |
---|---|---|
String | phoneNumber |
Returns
void
.
setPreinstallAttribution
Method signature
void setPreinstallAttribution(java.lang.String mediaSource,
java.lang.String campaign,
java.lang.String siteId)
Description
Specify the manufacturer or media source name to which the preinstall is attributed.
Input arguments
Type | Name | Description |
---|---|---|
String | mediaSource | Manufacturer or media source name for preinstall attribution. |
String | campaign | Campaign name for preinstall attribution. |
String | siteId | Site ID for preinstall attribution. |
Returns
void
.
setResolveDeepLinkURLs
Method signature
void setResolveDeepLinkURLs(java.lang.String... urls)
Description
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.
Input arguments
Type | Name | Description |
---|---|---|
String... | urls | Be sure to provide explicit URLs. |
Returns
void
Usage example
AppsFlyerLib.getInstance().setResolveDeepLinkURLs("clickdomain.com", "myclickdomain.com", "anotherclickdomain.com");
setSharingFilterForPartners
Added in V6.4
Method signature
void setSharingFilterForPartners(java.lang.String... partners)
This function replaces the deprecated setSharingFilter
and setSharingFilterForAllPartners
Description
Lets you configure how which partners should the SDK exclude from data-sharing.
Input arguments
Type | Name | Description |
---|---|---|
String... | partners | One or more partner identifiers you wish to exclude. Must include letters/digits and underscores only. Maximum partner ID length: 45 |
Note:
Make sure to use the exact partner ID (PID). Failing to do so may result in privacy-preservation breaches.
To find out the required partner IDs:
- Run the Get active integrations API for a list of all active integrations
- Use the
media_source_name
values from the API response as input values to the methodpartners
array.
Exceptions:
- For Twitter, use
twitter
(and nottwitter_int
)
Usage example
AppsFlyerLib.getInstance().setSharingFilterForPartners("partner1_int"); // Single partner
AppsFlyerLib.getInstance().setSharingFilterForPartners("partner1_int", "partner2_int"); // Multiple partners
AppsFlyerLib.getInstance().setSharingFilterForPartners("all"); // All partners
AppsFlyerLib.getInstance().setSharingFilterForPartners(); // Reset list (default)
AppsFlyerLib.getInstance().setSharingFilterForPartners("partner1_int") // Single partner
AppsFlyerLib.getInstance().setSharingFilterForPartners("partner1_int", "partner2_int") // Multiple partners
AppsFlyerLib.getInstance().setSharingFilterForPartners("all") // All partners
AppsFlyerLib.getInstance().setSharingFilterForPartners("") // Reset list (default)
setSharingFilter
Deprecated in V6.4
Method signature
void setSharingFilter(java.lang.String... partners)
This function is deprecated and has been replaced by setSharingFilterForPartners
Description
Stops events from propagating to the specified AppsFlyer partners.
(Deprecated and replaced by setSharingFilterForPartners)
Input arguments
Type | Name | Description |
---|---|---|
String... | partners | One or more partner identifiers. Must include letters/digits and underscores only. Maximum length: 45 |
Returns
void
setSharingFilterForAllPartners
Deprecated in V6.4
Method signature
void setSharingFilterForAllPartners()
This function is deprecated and has been replaced by setSharingFilterForPartners
Description
Stops events from propagating to all AppsFlyer partners. Overwrites setSharingFilter
.
Input arguments
This function takes no parameters.
Returns
void
setUserEmails
Method signature
void setUserEmails(AppsFlyerProperties.EmailsCryptType cryptMethod,
java.lang.String... emails)
Description
Set the user emails and encrypt them.
Input arguments
Type | Name | Description |
---|---|---|
AppsFlyerProperties.EmailsCryptType | cryptMethod | Encryption methods:
|
String... | emails | One or more user emails. |
Returns
void
.
start
Method signature
void start(Context context,
java.lang.String key,
AppsFlyerRequestListener listener)
Description
Starts the SDK.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application Context if calling in the Application onCreate method, Activity Context if calling after Activity's onResume method. |
String | key | Your AppsFlyer dev key |
AppsFlyerRequestListener | listener | (Optional) Listener for getting the request status. |
Returns
void
.
Usage example
See integrating the SDK for an example implementation.
stop
Method signature
void stop(boolean shouldStop,
Context context)
Description
Once this API is invoked, our SDK no longer communicates with our servers and stops functioning.
Useful when implementing user opt-in/opt-out.
SDK restart
After
stop(true)
was called, you need to callstop(false)
and only then callstart()
Input arguments
Type | Name | Description |
---|---|---|
boolean | shouldStop | should logging be stopped. |
Context | context | Application / Activity context. |
Returns
void
.
subscribeForDeepLink
Method signature
void subscribeForDeepLink(DeepLinkListener deepLinkListener,
long timeout)
Description
Input arguments
Type | Name | Description |
---|---|---|
DeepLinkListener | deepLinkListener | |
long | timeout | Optional. Units in milliseconds |
Returns
void
unregisterConversionListener
Method signature
void unregisterConversionListener()
Description
Unregister a previously registered AppsFlyerConversionListener
.
Input arguments
This function takes no parameters.
Returns
void
updateServerUninstallToken
Method signature
void updateServerUninstallToken(Context context,
java.lang.String token)
Description
For developers who use Firebase for purposes other than uninstall measurement. For more information, see uninstall measurement.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
String | token | Firebase Device Token. |
Returns
void
Usage example
AppsFlyerlib.getInstance().updateServerUninstallToken(getApplicationContext(), <TOKEN>);
AppsFlyerlib.getInstance().updateServerUninstallToken(getApplicationContext(), <TOKEN>);
validateAndLogInAppPurchase
Added in v6.14.0
Method signature
public abstract void validateAndLogInAppPurchase(@NonNull AFPurchaseDetails purchaseDetails,
@Nullable Map<String, String> additionalParameters,
@Nullable AppsFlyerInAppPurchaseValidationCallback validationCallback);
Description
The method validates a purchase event with the store and if the validation is successful, the SDK sends an af_purchase
event to AppsFlyer.
See detailed instructions in Validate and log in-app purchase.
Input arguments
Name | Type | Description |
---|---|---|
purchaseDetails * | AFPurchaseDetails | An object that encapsulates all data related to the purchase provided to the validateAndLogInAppPurchase method. |
additionalParameters | Map<String, String> | Additional parameters to log with the purchase. |
validationCallback * | AppsFlyerInAppPurchaseValidationCallback ` | A callback for delivering validation results. |
Returns
void
AFPurchaseDetails
An object that encapsulates all data related to the purchase provided to the validateAndLogInAppPurchase method.
data class AFPurchaseDetails(
val purchaseType: AFPurchaseType,
val purchaseToken: String,
val productId: String,
val price: String,
val currency: String
)
AFPurchaseDetails parameters
Name | Type | Description |
---|---|---|
purchaseType | AFPurchaseType | Field to distinguish between one-time purchases and subscriptions. The field can accept either subscription or one-time-purchase. |
purchaseToken | String | Token that uniquely identifies a purchase for a given item and user pair. Part of the Billing Library's Purchase class . To retrieve the token call the getPurchaseToken API |
productId | String | ID of the product item that has been purchased. Also part of the Billing Library's Purchase class . |
price | String | The full price of the one-time purchase or the subscription. Also part of the Billing Library's Purchase class . |
currency | String | Currency used to make the purchase. |
validateAndLogInAppPurchase (LEGACY)
Deprecated in v6.4
Method signature
void validateAndLogInAppPurchase(Context context,
java.lang.String publicKey,
java.lang.String signature,
java.lang.String purchaseData,
java.lang.String price,
java.lang.String currency,
java.util.Map<java.lang.String,java.lang.String> additionalParameters)
Description
API for server verification of in-app purchases. An af_purchase
event with the relevant values will be automatically logged if the validation is successful.
See detailed instructions in validating purchases.
Input arguments
Type | Name | Description |
---|---|---|
Context | context | Application / Activity context. |
String | publicKey | License Key obtained from the Google Play Console. |
String | signature | data.INAPP_DATA_SIGNATURE from onActivityResult(int requestCode, int resultCode, Intent data) |
String | purchaseData | data.INAPP_PURCHASE_DATA from onActivityResult(int requestCode, int resultCode, Intent data) |
String | price | Purchase price, should be derived from skuDetails.getStringArrayList("DETAILS_LIST") |
String | currency | Purchase currency, should be derived from skuDetails.getStringArrayList("DETAILS_LIST") |
Map<String, String> | additionalParameters | Freehand parameters to be logged with the purchase (if validated). |
Returns
void
.
waitForCustomerUserId
Method signature
void waitForCustomerUserId(boolean wait)
Description
This method defers the SDK initialization, until a customerUserID
is provided.
All in-app events and any other SDK API calls are discarded until the customerUserID
is provided and logged.
Input arguments
Type | Name | Description |
---|---|---|
boolean | wait |
Returns
void
.
Usage example
AppsFlyerLib.getInstance().waitForCustomerUserId(true);
AppsFlyerLib.getInstance().waitForCustomerUserId(true);
Updated 10 days ago