AppsFlyerLib
Overview
AppsFlyerLib
is the main class of the AppsFlyer iOS SDK, and encapsulates most of the methods.
To import AppsFlyerLib
:
// AppDelegate.h
#import <AppsFlyerLib/AppsFlyerLib.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, AppsFlyerLibDelegate>
@end
import AppsFlyerLib
Go back to the SDK reference index.
Properties
advertisingIdentifier (read-only)
Property declaration
@property(nonatomic, strong, readonly) NSString *advertisingIdentifier
Description
AppsFlyer SDK collect Apple's advertisingIdentifier
if the AdSupport.framework
included in the SDK.
You can disable this behavior by setting the disableAdvertisingIdentifier
to true
.
Type | Name |
---|---|
NSString | advertisingIdentifier |
anonymizeUser
Property declaration
@property(atomic) BOOL anonymizeUser;
Description
Opt-out logging for specific user
Type | Name |
---|---|
bool | anonymizeUser |
appInviteOneLinkID
Property declaration
@property(nonatomic, strong, nullable, setter = setAppInviteOneLink:) NSString * appInviteOneLinkID
Description
Set your OneLink ID from OneLink configuration. Used in User Invites to generate a OneLink.
Type | Name |
---|---|
NSString | appInviteOneLinkID |
appleAppID
Property declaration
@property(nonatomic, strong) NSString * appleAppID
Description
Use this property to set your app’s Apple ID(taken from the app’s page on iTunes Connect)
Type | Name |
---|---|
NSString | appleAppID |
appsFlyerDevKey
Property declaration
@property(nonatomic, strong) NSString * appsFlyerDevKey
Description
Use this property to set your AppsFlyer dev key.
Type | Name | Description |
---|---|---|
NSString | appsFlyerDevKey | Your AppsFlyer dev key. |
currencyCode
Property declaration
@property(nonatomic, strong, nullable) NSString *currencyCode
Description
In case of in app purchase events, you can set the currency code your user has purchased with.
The currency code is a 3 letter code according to ISO standards.
Usage example
[[AppsFlyerLib shared] setCurrencyCode:@"USD"];
AppsFlyerLib.shared().currencyCode = "USD"
customData
Setting
customData
before first launch will have the additional data included in installs, sessions, as well as in-app events.
Property declaration
@property(nonatomic, strong, nullable, setter = setAdditionalData:) NSDictionary * customData
Description
Use to add custom data to events' payload. You will receive it in the raw-data reports.
Type | Name |
---|---|
NSDictionary | customData |
customerUserID
Property declaration
@property(nonatomic, strong, nullable) NSString * customerUserID
Description
In case you use your own user ID in your app, you can set this property to that ID.
Enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and the other devices’ IDs
Type | Name |
---|---|
NSString | customerUserID |
deepLinkDelegate
Property declaration
@property(weak, nonatomic) id<AppsFlyerDeepLinkDelegate> deepLinkDelegate
Description
Delegate property of an object, that conforms to DeepLinkDelegate protocol and implements its methods.
Type | Name |
---|---|
DeepLinkDelegate | deepLinkDelegate |
Usage example
AppsFlyerLib.shared().deepLinkDelegate = self
deepLinkTimeout
Description
Request timeout for Deferred Deeplinking.
Units in milliseconds.
Property declaration
@property(nonatomic) NSUInteger deepLinkTimeout
Type | Name |
---|---|
NSUInteger | deepLinkTimeout |
delegate
Description
AppsFlyer delegate. See AppsFlyerLibDelegate.
Property declaration
@property (nonatomic, weak) id<AppsFlyerLibDelegate> delegate;
Type | Name |
---|---|
AppsFlyerLibDelegate | delegate |
disableAdvertisingIdentifier
Property declaration
@property (nonatomic) int disableAdvertisingIdentifier;
Description
If AdSupport.framework
isn't disabled, the SDK collects the Apple advertisingIdentifier
.
You can disable this behavior by setting the following property to YES
.
Type | Name |
---|---|
NSString | advertisingIdentifier |
disableAppleAdsAttribution
Property declaration
@property(nonatomic) BOOL disableAppleAdsAttribution
Description
Disables AdServices framework-based attribution for Apple Search Ads.
Type | Name |
---|---|
bool | disableAppleAdsAttribution |
disableCollectASA
Property declaration
@property(atomic) BOOL disableCollectASA;
Description
Disables the collection of data from the iAd Framework. This API has no effect in v6.12.3 and above, where the iAd Framework is no longer in use.
Type | Name |
---|---|
bool | disableCollectASA |
disableIDFVCollection
Property declaration
@property(nonatomic) BOOL disableIDFVCollection;
Description
To disable app vendor identifier (IDFV) collection, set disableIDFVCollection
to YES
.
Type | Name |
---|---|
bool | disableIDFVCollection |
disableSKAdNetwork
Property declaration
@property(nonatomic) BOOL disableSKAdNetwork
Description
Type | Name |
---|---|
bool | disableSKAdNetwork |
facebookDeferredAppLink
Property declaration
@property (nonatomic, nullable) int *facebookDeferredAppLink;
Description
Manually set Facebook deferred app link.
Type | Name |
---|---|
NSString | advertisingIdentifier |
host (read-only)
Property declaration
@property(nonatomic, strong, readonly) NSString *host
Description
This property accepts a string value representing the host name for all endpoints. To set the host, use setHost.
To use default SDK endpoint – set value to nil
.
Type | Name |
---|---|
NSString | host |
hostPrefix (read-only)
Property declaration
@property(nonatomic, strong, readonly) NSString *hostPrefix
Description
This property accepts a string value representing the prefix hostname for all endpoints. To set the host, use setHost.
Type | Name |
---|---|
NSString | hostPrefix |
isDebug
Property declaration
@property(nonatomic) BOOL isDebug;
Description
Prints SDK messages to the console log. Should be disabled for production builds.
Type | Name |
---|---|
bool | isDebug |
isStopped
Property declaration
@property(atomic) BOOL isStopped;
SDK Restart
Set
isStopped = true
and then setisStopped = false
No need to call
start()
Description
API to shut down all SDK activities. This will disable all requests from the SDK except for those related to fetching SKAd Network data from the server.
Type | Name |
---|---|
bool | isStopped |
minTimeBetweenSessions
Property declaration
@property(atomic) NSUInteger minTimeBetweenSessions;
Description
Set a custom value for the minimum required time between sessions.
Input arguments
Type | Name | Description |
---|---|---|
NSUInteger | minTimeBetweenSessions | 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 |
oneLinkCustomDomains
Property declaration
@property(nonatomic, nullable) NSArray<NSString *> *oneLinkCustomDomains;
Description
For advertisers who use vanity OneLinks.
Type | Name |
---|---|
NSArray<NSString *> | oneLinkCustomDomains |
phoneNumber
Property declaration
@property(nonatomic, nullable) NSString *phoneNumber
Description
Type | Name |
---|---|
NSString | phoneNumber |
resolveDeepLinkURLs
Property declaration
@property(nonatomic, nullable) NSArray<NSString *> *resolveDeepLinkURLs;
Description
Type | Name |
---|---|
NSArray<NSString *> | resolveDeepLinkURLs |
Usage example
Some third-party services such as email service providers (ESPs) wrap links in emails with their own click recording domains. Some even allow you to set your own click recording domains. If OneLink is wrapped in such domains, it might limit its functionality.
To overcome this issue, use setResolveDeepLinkURLs
to get the OneLink from click domains that launch the app. Make sure to call this API before SDK initialization.
For example, you have three click domains that redirect to your OneLink which is https://mysubdomain.onelink.me/abCD. Use this API to get the OneLink that your click domains redirect to. This API method receives a list of domains that the SDK resolves.
[AppsFlyerLib shared].resolveDeepLinkURLs = @[@"example.com",@"click.example.com"];
AppsFlyerLib.shared().resolveDeepLinkURLs = ["example.com", "click.example.com"]
This allows you to use your click domain while preserving OneLink functionality. The click domains are responsible for launching the app. The API, in turn, gets the OneLink from these click domains, and then you can use the data from this OneLink to deep-link and customize user content.
sharingFilter
Property declaration
@property(nonatomic, nullable) NSArray<NSString *> *sharingFilter;
Description
Type | Name |
---|---|
NSArray<NSString *> | sharingFilter |
shouldCollectDeviceName
Property declaration
@property(nonatomic) BOOL shouldCollectDeviceName;
Description
Set this flag to YES, to collect the current device name(e.g. “My iPhone”).
Type | Name |
---|---|
bool | shouldCollectDeviceName |
useReceiptValidationSandbox
Property declaration
@property (nonatomic) BOOL useReceiptValidationSandbox;
Description
In-app purchase receipt validation Apple environment(production or sandbox).
Type | Name |
---|---|
bool | useReceiptValidationSandbox |
useUninstallSandbox
Property declaration
@property (nonatomic) BOOL useUninstallSandbox;
Description
Set this flag to test uninstall on Apple environment(production or sandbox).
Type | Name |
---|---|
bool | useUninstallSandbox |
Methods
addPushNotificationDeepLinkPath
Method signature
- (void)addPushNotificationDeepLinkPath:(NSArray<NSString *> *)deepLinkPath;
addPushNotificationDeepLinkPath(deepLinkPath: [String])
Description
Adds array of keys, which are used to compose key path to resolve deeplink from push notification payload.
Input arguments
Type | Name |
---|---|
NSArray<NSString *> | deepLinkPath |
Returns
void
.
Usage example
Basic configuration:
[AppsFlyerLib shared] addPushNotificationDeepLinkPath:@[@"af_push_link"]]
AppsFlyerLib.shared().addPushNotificationDeepLinkPath(["af_push_link"])
Advanced configuration:
[AppsFlyerLib shared] addPushNotificationDeepLinkPath:@[@"deeply", @"nested", @"deep_link"]]
AppsFlyerLib.shared().addPushNotificationDeepLinkPath(["deeply", "nested", "deep_link"])
This call matches the following payload structure:
{
"deeply": {
"nested": {
“deep_link”: “https://yourdeeplink2.onelink.me”
}
}
}
appendParametersToDeepLinkingURL
Method signature
(void)appendParametersToDeepLinkingURLWithString:(NSString *)containsString parameters:(NSDictionary<NSString *, NSString*> *)parameters;
appendParametersToDeeplinkURL(contains: String, parameters: [String : String])
Description
Matches URLs that contain contains
as a substring and appends query parameters to them. In case the URL does not match, parameters are not appended to it.
Call this method before calling
start
Input arguments
Type | Name | Description |
---|---|---|
NSString | contains | The string to check in URL. |
NSDictionary | parameters | Parameters to append to the deeplink url after it passed validation. |
Returns
void
.
continue
Method signature
- (id)continueUserActivity:(id)userActivity
restorationHandler:
(void (^_Nullable)(int *_Nullable))restorationHandler;
AppsFlyerLib.shared().continue(userActivity: NSUserActivity?, restorationHandler: (([Any]?) -> Void)?)
Description
Allow AppsFlyer to handle restoration from an `NSUserActivity
. Use this method to handle Universal links.
Input arguments
Type | Name | Description |
---|---|---|
NSUserActivity | userActivity | The NSUserActivity that was passed to your app delegate |
void (^_Nullable)(int *_Nullable) | restorationHandler | pass nil |
Returns
void
.
enableFacebookDeferderedApplinks
Method signature
- (void)enableFacebookDeferredApplinksWithClass:(Class _Nullable)facebookAppLinkUtilityClass;
enableFacebookDeferredApplinks(with:AnyClass?)
Description
Enable the collection of Facebook Deferred AppLinks.
- Requires Facebook SDK and Facebook app on target/client device.
- This API must be invoked prior to initializing the AppsFlyer SDK in order to function properly
Input arguments
Type | Name | Description |
---|---|---|
FBSDKAppLinkUtility | facebookAppLinkUtilityClass |
Returns
void
.
enableTCFDataCollection
Method signature
- (void)enableTCFDataCollection:(BOOL)flag;
func enableTCFDataCollection(_ flag: Bool)
Description
Enables the collection of Transparency and Consent Framework (TCF) data from NSUserDefaults
. The data was placed in UserDefaults
by the device's TCF v2.2 compatible Consent Management Platform (CMP).
Input arguments
Type | Name | Description |
---|---|---|
Bool | flag | A Boolean value to enable or disable the collection of TCF data. |
Returns
void
.
getAppsFlyerUID
Method signature
- (NSString *)getAppsFlyerUID;
getAppsFlyerUID()
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
This method takes no input arguments.
Returns
Type | Description |
---|---|
NSString | AppsFlyer internal ID. |
getSDKVersion
Method signature
- (NSString *)getSDKVersion;
getSDKVersion()
Description
Get SDK version.
Input arguments
This method takes no input arguments.
Returns
Type | Description |
---|---|
NSString | The AppsFlyer SDK version. |
handleOpen
Method signature
- (void)handleOpenUrl:(id)url options:(id)options;
AppsFlyerLib.shared().handleOpen(url: URL?, options: [AnyHashable : Any]?)
Description
Call this method from inside of your AppDelegate openURL
method.
This method handles URI-scheme for iOS 9 and above.
Input arguments
Type | Name | Description |
---|---|---|
NSURL | url | The URL that was passed to your app delegate. |
AnyHashable | options | The options dictionary that was passed to your AppDelegate. |
Returns
void
.
handlePushNotification
Method signature
- (void)handlePushNotification:(NSDictionary * _Nullable)pushPayload;
AppsFlyerLib.shared().handlePushNotification(pushPayload: [AnyHashable : Any]?)
Description
Enable AppsFlyer to handle a push notification.
Input arguments
Type | Name | Description |
---|---|---|
AnyHashable | pushPayload | The userInfo from received remote notification. Unless addPushNotificationDeepLinkPath is used, the data must be under the @“af” key. |
Returns
void
.
logAdRevenue
Added in v6.15.0
Method signature
-(void)logAdRevenue:(AFAdRevenueData *)adRevenueData additionalParameters:(NSDictionary * **_Nullable**)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 | NSDictionary * _Nullable | 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
AFAdRevenueData {
(NSString * **_Nonnull**)monetizationNetwork
(AppsFlyerAdRevenueMediationNetworkType)mediationNetwork
(NSString * **_Nonnull**)currencyIso4217Code
(NSNumber * **_Nonnull**)eventRevenue
}
AFAdRevenueData parameters
Name | Type | Description |
---|---|---|
monetizationNetwork | String | The monetization network name. |
mediationNetwork | AppsFlyerAdRevenueMediationNetworkType | The mediation network enum. |
currencyIso4217Code | String | The ad revenue event currency is a String validated against currencyIso4217Code |
eventRevenue | Double | The ad revenue event amount. |
AppsFlyerAdRevenueMediationNetworkType
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:(NSString *)eventName withValues:(NSDictionary * _Nullable)values;
logEvent(eventName: String, withValues: [AnyHashable : Any]?)
Description
Use this method to log an event with event parameters.
Input arguments
Type | Name | Description |
---|---|---|
NSString | eventName | Contains name of event that could be provided from predefined constants |
AnyHashable | withValues | dictionary of values for handling by backend |
Returns
void
.
logEvent
Method signature
- (void)logEventWithEventName:(NSString *)eventName
eventValues:(NSDictionary<NSString * , id> * _Nullable)eventValues
completionHandler:(void (^ _Nullable)(NSDictionary<NSString *, id> * _Nullable dictionary, NSError * _Nullable error))completionHandler;
logEvent(eventName: String, withValues: [AnyHashable : Any]?, completionHandler:(([String : Any]?, Error?) -> Void)?)
Description
Use this method to log an event with event parameters, and pass a completion handler to handle event submissions success and failure.
Input arguments
Type | Name | Description |
---|---|---|
NSString | eventName | Contains name of event that could be provided from predefined constants |
AnyHashable | withValues | dictionary of values for handling by backend |
(^ _Nullable)(NSDictionary<NSString _, id> _ _Nullable dictionary, NSError * _Nullable error)) | completionHandler |
Returns
void
.
logLocation
Method signature
- (void)logLocation:(double)longitude latitude:(double)latitude;
logLocation(longitude: Double, latitude: Double)
Description
To log location for geo-fencing. Does the same as code below.
Input arguments
Type | Name | Description |
---|---|---|
Double | longitude | The location longitude |
Double | latitude | The location latitude |
Returns
void
.
performOnAppAttribution
Method signature
- (void)performOnAppAttributionWithURL:(NSURL * _Nullable)URL;
performOnAppAttribution(with:URL?)
Description
Used to manually trigger onAppOpenAttribution
delegate.
Input arguments
Type | Name | Description |
---|---|---|
NSURL | URL | The parameter to resolve into -[AppsFlyerLibDelegate onAppOpenAttribution:] |
Returns
void
.
registerUninstall
Method signature
- (void)registerUninstall:(NSData * _Nullable)deviceToken;
registerUninstall(deviceToken: Data?)
Description
Register uninstall - you should register for remote notification and provide AppsFlyer the push device token.
Input arguments
Type | Name | Description |
---|---|---|
NSData | deviceToken | The deviceToken is from didRegisterForRemoteNotificationsWithDeviceToken . |
Returns
void
.
setConsentData
Method signature
.setConsentData(afConsent: AppsFlyerConsent)
- (void)setConsentData:(AppsFlyerConsent) afConsent
Description
Transfers consent data to the SDK.
Input arguments
Type | Name | Description |
---|---|---|
AppsFlyerConsent | afConsent | An object containing user consent data |
setCurrentDeviceLanguage
Method signature
- (void)setCurrentDeviceLanguage:(NSString *)currentDeviceLanguage
Description
Use this method to set the device language in the SDK and pass it to AppsFlyer.
Input arguments
Type | Name | Description |
---|---|---|
NSString | currentDeviceLanguage | Current device language. |
Usage example
NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0]
[[AppsFlyerLib shared] setCurrentDeviceLanguage: @language];
let language = NSLocale.current.languageCode
AppsFlyerLib.shared().currentDeviceLanguage = language
setHost
Method signature
(void)setHost:(NSString *)host withHostPrefix:(NSString *)hostPrefix;
setHost(host: String, withHostPrefix: String)
Description
This function sets the hostname and prefix hostname for all the endpoints.
Note: Starting with SDK V6.11, if the host value is empty or null, the API call will be ignored.
Input arguments
Type | Name | Description |
---|---|---|
NSString | host | hostname. |
NSString | withHostPrefix | Required. host prefix. |
Returns
void
.
Usage example
[[AppsFlyerLib shared] setHost:@"example.com" withHostPrefix:@"my_host_prefix"];
AppsFlyerLib.shared().setHost("example.com", withHostPrefix: "my_host_prefix")
setPartnerData
Method signature
- (void)setPartnerDataWithPartnerId:(NSString * _Nullable)partnerId partnerInfo:(NSDictionary<NSString *, id> * _Nullable)partnerInfo;
setPartnerData(partnerId: String?, partnerInfo: [String : Any]?)
Description
Allows sending custom data for partner integration purposes.
Input arguments
Type | Name | Description |
---|---|---|
NSString | partnerId | ID of the partner (usually has _int suffix) |
NSDictionary<NSString _, id> _ _Nullable | partnerInfo | customer data, depends on the integration nature with specific partner |
Returns
void
.
Usage example
NSDictionary *partnerInfo = @{
@"puid": @"123456789",
};
[[AppsFlyerLib shared] setPartnerDataWithPartnerId: @"test_int" partnerInfo:partnerInfo];
let partnerInfo = [
"puid":"123456789",
]
AppsFlyerLib.shared().setPartnerData(partnerId:"test_int", partnerInfo:partnerInfo)
setSharingFilterForPartners
Added in V6.4
Method signature
- (void)setSharingFilterForPartners:(NSArray<NSString *> * _Nullable)sharingFilter;
This function replaces the deprecated setSharingFilterForAllPartners
Description
Lets you configure which partners should the SDK exclude from data-sharing.
Input arguments
Type | Name | Description |
---|---|---|
NSArray<NSString _> _ _Nullable | sharingFilter | 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 Apple Search Ads use
Apple Search Ads
(and notiossearchads_int
). - For Twitter, use
twitter
(and nottwitter_int
)
Usage example
[[AppsFlyerLib shared] setSharingFilterForPartners:@[@"examplePartner1_int"]]; // 1 partner
[[AppsFlyerLib shared] setSharingFilterForPartners:@[@"examplePartner1_int", @"examplePartner2_int"]]; // multiple partners
[[AppsFlyerLib shared] setSharingFilterForPartners:@[@"all"]]; // All partners
[[AppsFlyerLib shared] setSharingFilterForPartners:nil]; // Reset list (default)
AppsFlyerLib.shared().setSharingFilterForPartners(["examplePartner1_int"]) // 1 partner
AppsFlyerLib.shared().setSharingFilterForPartners(["examplePartner2_int", "examplePartner1_int"]) // multiple partners
AppsFlyerLib.shared().setSharingFilterForPartners(["all"]) // All partners
AppsFlyerLib.shared().setSharingFilterForPartners(nil) // Reset list (default)
setSharingFilterForAllPartners
Deprecated in V6.4
Method signature
- (void)setSharingFilterForAllPartners;
setSharingFilterForAllPartners()
This function is deprecated and has been replaced by setSharingFilterForPartners
Description
Block an event from being shared with integrated partners.
Input arguments
This method takes no input arguments.
Returns
void
setUserEmails
Method signature
- (void)setUserEmails:(NSArray<NSString *> * _Nullable)userEmails withCryptType:(EmailCryptType)type;
setUserEmails(userEmails: [String]?, with: EmailCryptType)
Description
Use this to set the user email(s).
Note: MD-5
and SHA-1
encryption types are deprecated starting with SDK V6.9.0. Currently, only SHA-256
and NONE
are supported.
Input arguments
Type | Name | Description |
---|---|---|
NSArray<NSString *> | userEmails | Email array. |
EmailCryptType | type | Encryption type. |
Returns
void
.
shared
Method signature
(AppsFlyerLib *)shared;
Description
Gets the singleton instance of the AppsFlyerLib
class, creating it if necessary.
Usage example
AppsFlyerLib.shared()
start
Method signature
- (void)start;
(void) start()
Description
Starts the SDK.
Input arguments
This method takes no input arguments.
Returns
void
.
start
Method signature
- (void)startWithCompletionHandler:(void (^ _Nullable)(NSDictionary<NSString *, id> * _Nullable dictionary, NSError * _Nullable error))completionHandler;
start(completionHandler: (([String : Any]?, Error?) -> Void)?)
Description
Start the SDK with a completion handler.
Input arguments
Type | Name | Description |
---|---|---|
void (^ _Nullable)(NSDictionary<NSString _, id> _ _Nullable dictionary, NSError * _Nullable error) | completionHandler |
Returns
void
.
validateAndLogInAppPurchase
(Supported from SDK v.6.14.1)
Method signature
typedef void (^AFSDKValidateAndLogCompletion)(AFSDKValidateAndLogResult * _Nullable result);
- (void)validateAndLogInAppPurchase:(AFSDKPurchaseDetails *)details
extraEventValues:(NSDictionary * _Nullable)extraEventValues
completionHandler:(AFSDKValidateAndLogCompletion)completionHandler NS_AVAILABLE(10_7, 7_0);
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 parameters
Name | Type | Description |
---|---|---|
details * | 'AFSDKPurchaseDetails'* | An object that encapsulates all data related to the purchase provided to the validateAndLogInAppPurchase method. |
extraEventValues | NSDictionary * _Nullable | An optional dictionary containing additional parameters to log with the purchase event. |
completionHandler * | AFSDKValidateAndLogCompletion | A completion handler block that is called with the result of the purchase validation and logging. |
Returns
void
.
AFSDKPurchaseDetails
An object that encapsulates all data related to the purchase provided to the validateAndLogInAppPurchase
method.
AFSDKPurchaseDetails parameters
Name | Type | Description |
---|---|---|
productId | String | The product identifier for the purchase. |
price | String | The price of the product. |
currency | String | The currency used for the billing operation. |
transactionId | String | A specific identifier for the transaction. |
validateAndLogInAppPurchase (LEGACY)
(Supported until SDK v.6.14.0)
Method signature
- (void)validateAndLogInAppPurchase:(id)productIdentifier
price:(id)price
currency:(id)currency
transactionId:(id)transactionId
additionalParameters:(id)params
success:(void (^_Nullable)(int *))successBlock
failure:
(void (^_Nullable)(int *_Nullable,
id _Nullable))failedBlock;
validateAndLog(inAppPurchase: String?, price: String?, currency: String?, transactionId: String?, additionalParameters: [AnyHashable : Any]?, success: ([AnyHashable : Any]) -> Void)?, failure: ((Error?, Any?) -> Void)?)
Description
To log and validate in-app purchases you can call this method from the [completeTransaction
] method in your SKPaymentTransactionObserver
.
Input arguments
Type | Name | Description |
---|---|---|
NSString | productIdentifier | inAppPurchase in Swift. |
NSString | price | |
NSString | currency | |
NSString | transactionId | |
NSDictionary | additionalParameters | |
void (^_Nullable)(int *))successBlock | successBlock | Completion handler for successful logging and validation. |
void (^_Nullable)(int *_Nullable, id _Nullable)) | failedBlock | Completion handler for failure in logging and validation. |
Returns
void
.
waitForATTUserAuthorization
Method signature
- (void)waitForATTUserAuthorizationWithTimeoutInterval:(id)timeoutInterval;
waitForATTUserAuthorization(timeoutInterval:)
Description
Waits for request user authorization to access app-related data
Input arguments
Type | Name | Description |
---|---|---|
NSInteger | timeoutInterval |
Usage example
if (@available(iOS 14, *)) {
[[AppsFlyerLib shared] waitForATTUserAuthorizationWithTimeoutInterval:60];
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status){
}];
}
if #available(iOS 14, *) {
AppsFlyerLib.shared().waitForATTUserAuthorization(withTimeoutInterval: 60)
ATTrackingManager.requestTrackingAuthorization { (status) in
}
}
Returns
void
.
Updated about 2 months ago