From 1e8a4b7270ef913f4ed11c74a1403ed3e0af9397 Mon Sep 17 00:00:00 2001 From: Vitaly Sokolov Date: Thu, 6 Aug 2020 19:09:14 +0300 Subject: [PATCH 01/33] SDK 6.0 update + new APIs: - waitForAdvertisingIdentifierWithTimeoutInterval - requestTrackingAuthorization --- .npmignore | 1 + CHANGELOG.md | 9 + index.d.ts | 13 +- index.js | 87 ++++---- ios/AppsFlyerCrossPromotionHelper.h | 26 ++- ios/{AppsFlyerTracker.h => AppsFlyerLib.h} | 245 +++++++++++---------- ios/AppsFlyerLinkGenerator.h | 2 +- ios/AppsFlyerShareInviteHelper.h | 6 +- ios/RNAppsFlyer.h | 1 + ios/RNAppsFlyer.m | 165 +++++++++----- react-native-appsflyer.podspec | 2 +- 11 files changed, 318 insertions(+), 239 deletions(-) rename ios/{AppsFlyerTracker.h => AppsFlyerLib.h} (80%) diff --git a/.npmignore b/.npmignore index 46b411bf..64e51562 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,2 @@ /examples +/SampleApp \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 16eb4cb8..9d28939f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Versions +## 6.0.0-Beta + +- iOS SDK 6.0.0-Beta +- Android SDK 5.4.1 + +_APIs renamed:_ + +track -> log + ## 5.4.1 - Android and iOS SDK 5.4.1 - iOS lifecycle now handled natively and not from _handleAppStateChange diff --git a/index.d.ts b/index.d.ts index d04b009e..826b07fe 100644 --- a/index.d.ts +++ b/index.d.ts @@ -60,7 +60,7 @@ declare module "react-native-appsflyer" { stopTracking(isStopTracking: boolean, successC?: SuccessCB): void setAppInviteOneLinkID(oneLinkID: string, successC?: SuccessCB): void generateInviteLink(params: GenerateInviteLinkParams, successC?: SuccessCB, errorC?: ErrorCB): void - trackCrossPromotionImpression(appId: string, campaign: string): void + trackCrossPromotionImpression(appId: string, campaign: string, parameters: object): void trackAndOpenStore(appId: string, campaign: string, params: object): void setCurrencyCode(currencyCode: string, successC: SuccessCB): void setDeviceTrackingDisabled(isDeviceTrackingDisabled: boolean, successC: SuccessCB): void @@ -75,14 +75,17 @@ declare module "react-native-appsflyer" { * */ trackAppLaunch(): void trackLocation(longitude: number, latitude: number, callback: SuccessCB): void + waitForAdvertisingIdentifierWithTimeoutInterval(timeoutInterval: number, successC?: SuccessCB, errorC?: ErrorCB): void + requestTrackingAuthorization(successC, errorC): void + /** * For Android Only * */ - sendDeepLinkData(callback:any): void - setCollectIMEI(isCollect:boolean, successC?:SuccessCB): void - setCollectAndroidID(isCollect:boolean, successC?:SuccessCB): void - updateServerUninstallToken(token:string, successC?:SuccessCB): void + sendDeepLinkData(callback: any): void + setCollectIMEI(isCollect: boolean, successC?: SuccessCB): void + setCollectAndroidID(isCollect: boolean, successC?: SuccessCB): void + updateServerUninstallToken(token: string, successC?: SuccessCB): void /** @deprecated - please use updateServerUninstallToken **/ setGCMProjectNumber(gcmProjectNumber:any, successC?:SuccessCB, errorC?:ErrorCB): void /** @deprecated - please use updateServerUninstallToken **/ diff --git a/index.js b/index.js index c8f8cab3..d2a0cac4 100755 --- a/index.js +++ b/index.js @@ -16,8 +16,8 @@ function initSdkPromise(options): Promise { function initSdk(options, success, error): Promise { options.onInstallConversionDataListener = eventsMap["onInstallConversionData"] - ? true - : false; + ? true + : false; if (success && error) { //initSdk is a callback function @@ -205,8 +205,8 @@ appsFlyer.generateInviteLink = (parameters, success, error) => { * @param appId promoted App ID. * @param campaign cross promotion campaign. */ -appsFlyer.trackCrossPromotionImpression = (appId, campaign) => { - return RNAppsFlyer.trackCrossPromotionImpression(appId, campaign); +appsFlyer.trackCrossPromotionImpression = (appId, campaign, parameters) => { + return RNAppsFlyer.trackCrossPromotionImpression(appId, campaign, parameters); }; /** @@ -250,22 +250,22 @@ appsFlyer.setCurrencyCode = (currencyCode, successC) => { appsFlyer.onInstallConversionData = callback => { const listener = appsFlyerEventEmitter.addListener( - "onInstallConversionDataLoaded", - _data => { - if (callback && typeof callback === typeof Function) { - try { - let data = JSON.parse(_data); - callback(data); - } catch (_error) { - //throw new AFParseJSONException("..."); - //TODO: for today we return an error in callback - callback(new AFParseJSONException("Invalid data structure", _data)); + "onInstallConversionDataLoaded", + _data => { + if (callback && typeof callback === typeof Function) { + try { + let data = JSON.parse(_data); + callback(data); + } catch (_error) { + //throw new AFParseJSONException("..."); + //TODO: for today we return an error in callback + callback(new AFParseJSONException("Invalid data structure", _data)); + } } } - } ); - eventsMap["onInstallConversionData"] = listener; + eventsMap["onInstallConversionData"] = listener; // unregister listener (suppose should be called from componentWillUnmount() ) return function remove() { @@ -276,22 +276,22 @@ appsFlyer.onInstallConversionData = callback => { appsFlyer.onInstallConversionFailure = callback => { const listener = appsFlyerEventEmitter.addListener( - "onInstallConversionFailure", - _data => { - if (callback && typeof callback === typeof Function) { - try { - let data = JSON.parse(_data); - callback(data); - } catch (_error) { - //throw new AFParseJSONException("..."); - //TODO: for today we return an error in callback - callback(new AFParseJSONException("Invalid data structure", _data)); + "onInstallConversionFailure", + _data => { + if (callback && typeof callback === typeof Function) { + try { + let data = JSON.parse(_data); + callback(data); + } catch (_error) { + //throw new AFParseJSONException("..."); + //TODO: for today we return an error in callback + callback(new AFParseJSONException("Invalid data structure", _data)); + } } } - } ); - eventsMap["onInstallConversionFailure"] = listener; + eventsMap["onInstallConversionFailure"] = listener; // unregister listener (suppose should be called from componentWillUnmount() ) return function remove() { @@ -304,17 +304,17 @@ appsFlyer.onAppOpenAttribution = callback => { //console.log("onAppOpenAttribution is called" ); const listener = appsFlyerEventEmitter.addListener( - "onAppOpenAttribution", - _data => { - if (callback && typeof callback === typeof Function) { - try { - let data = JSON.parse(_data); - callback(data); - } catch (_error) { - callback(new AFParseJSONException("Invalid data structure", _data)); + "onAppOpenAttribution", + _data => { + if (callback && typeof callback === typeof Function) { + try { + let data = JSON.parse(_data); + callback(data); + } catch (_error) { + callback(new AFParseJSONException("Invalid data structure", _data)); + } } } - } ); @@ -374,6 +374,19 @@ appsFlyer.setSharingFilter = (partners, successC, errorC) => { return RNAppsFlyer.setSharingFilter(partners, successC, errorC); } +/** + * iOS only + */ +appsFlyer.waitForAdvertisingIdentifierWithTimeoutInterval = (timeoutInterval, successC, errorC) => { + return RNAppsFlyer.waitForAdvertisingIdentifierWithTimeoutInterval(timeoutInterval * 1000, successC, errorC); +} +/** + * iOS only + */ +appsFlyer.requestTrackingAuthorization = (successC, errorC) => { + RNAppsFlyer.requestTrackingAuthorizationWith(successC, errorC); +} + function AFParseJSONException(_message, _data) { this.message = _message; this.data = _data; diff --git a/ios/AppsFlyerCrossPromotionHelper.h b/ios/AppsFlyerCrossPromotionHelper.h index 5c1c17f4..4a0e93aa 100644 --- a/ios/AppsFlyerCrossPromotionHelper.h +++ b/ios/AppsFlyerCrossPromotionHelper.h @@ -11,37 +11,39 @@ NS_ASSUME_NONNULL_BEGIN /** - AppsFlyer allows you to track and attribute installs originating + AppsFlyer allows you to log and attribute installs originating from cross promotion campaigns of your existing apps. Afterwards, you can optimize on your cross-promotion traffic to get even better results. */ @interface AppsFlyerCrossPromotionHelper : NSObject /** - To track an impression use the following API call. + To log an impression use the following API call. Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard. - + @param appID Promoted App ID @param campaign A campaign name - */ -+ (void)trackCrossPromoteImpression:(nonnull NSString *)appID - campaign:(nullable NSString *)campaign; + @param parameters Additional params like `@{@"af_sub1": @"val", @"custom_param": @"val2" }` +*/ ++ (void)logCrossPromoteImpression:(nonnull NSString *)appID + campaign:(nullable NSString *)campaign + parameters:(nullable NSDictionary *)parameters; /** iOS allows you to utilize the StoreKit component to open the App Store while remaining in the context of your app. More details at https://support.appsflyer.com/hc/en-us/articles/115004481946-Cross-Promotion-Tracking#tracking-cross-promotion-impressions - + @param appID Promoted App ID @param campaign A campaign name @param parameters Additional params like `@{@"af_sub1": @"val", @"custom_param": @"val2" }` @param openStoreBlock Contains promoted `clickURL` */ -+ (void)trackAndOpenStore:(nonnull NSString *)appID - campaign:(nullable NSString *)campaign - paramters:(nullable NSDictionary *)parameters - openStore:(void (^)(NSURLSession *urlSession, NSURL *clickURL))openStoreBlock; ++ (void)logAndOpenStore:(nonnull NSString *)appID + campaign:(nullable NSString *)campaign + parameters:(nullable NSDictionary *)parameters + openStore:(void (^)(NSURLSession *urlSession, NSURL *clickURL))openStoreBlock; @end -NS_ASSUME_NONNULL_END +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/ios/AppsFlyerTracker.h b/ios/AppsFlyerLib.h similarity index 80% rename from ios/AppsFlyerTracker.h rename to ios/AppsFlyerLib.h index f0978792..967b8fc6 100644 --- a/ios/AppsFlyerTracker.h +++ b/ios/AppsFlyerLib.h @@ -1,8 +1,8 @@ // -// AppsFlyerTracker.h +// AppsFlyerLib.h // AppsFlyerLib // -// AppsFlyer iOS SDK 5.2.0 (964) +// AppsFlyer iOS SDK 5.1.0 (931) // Copyright (c) 2012-2019 AppsFlyer Ltd. All rights reserved. // @@ -151,7 +151,7 @@ typedef enum { Conform and subscribe to this protocol to allow getting data about conversion and install attribution */ -@protocol AppsFlyerTrackerDelegate +@protocol AppsFlyerLibDelegate /** `conversionInfo` contains information about install. @@ -189,24 +189,24 @@ typedef enum { @end /** - You can track installs, app updates, sessions and additional in-app events + You can log installs, app updates, sessions and additional in-app events (including in-app purchases, game levels, etc.) to evaluate ROI and user engagement. The iOS SDK is compatible with all iOS/tvOS devices with iOS version 7 and above. - + @see [SDK Integration Validator](https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS) for more information. - + */ -@interface AppsFlyerTracker : NSObject +@interface AppsFlyerLib : NSObject /** - Gets the singleton instance of the AppsFlyerTracker class, creating it if + Gets the singleton instance of the AppsFlyerLib class, creating it if necessary. - - @return The singleton instance of AppsFlyerTracker. + + @return The singleton instance of AppsFlyerLib. */ -+ (AppsFlyerTracker *)sharedTracker; ++ (AppsFlyerLib *)shared; /** In case you use your own user ID in your app, you can set this property to that ID. @@ -216,7 +216,7 @@ typedef enum { /** In case you use custom data and you want to receive it in the raw reports. - + @see [Setting additional custom data](https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS#setting-additional-custom-data) for more information. */ @property(nonatomic, strong, nullable, setter = setAdditionalData:) NSDictionary * customData; @@ -231,30 +231,34 @@ typedef enum { */ @property(nonatomic, strong) NSString * appleAppID; +/** + AppsFlyer SDK collect Apple's `advertisingIdentifier` if the `AdSupport.framework` included in the SDK. + You can disable this behavior by setting the following property to YES +*/ +@property(nonatomic) BOOL disableAdvertisingIdentifier; + +@property(nonatomic, strong, readonly) NSString *advertisingIdentifier; + +- (void)waitForAdvertisingIdentifierWithTimeoutInterval:(NSTimeInterval)timeoutInterval; + /** 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 - + Objective-C: - +
- [[AppsFlyerTracker sharedTracker] setCurrencyCode:@"USD"];
+ [[AppsFlyerLib shared] setCurrencyCode:@"USD"];
  
- + Swift: - +
- AppsFlyerTracker.shared().currencyCode = "USD"
+ AppsFlyerLib.shared().currencyCode = "USD"
  
*/ @property(nonatomic, strong, nullable) NSString *currencyCode; -/** - AppsFlyer SDK collect Apple's `advertisingIdentifier` if the `AdSupport.framework` included in the SDK. - You can disable this behavior by setting the following property to YES - */ -@property(atomic) BOOL disableAppleAdSupportTracking; - /** Prints SDK messages to the console log. This property should only be used in `DEBUG` mode. The default value is `NO` @@ -272,19 +276,19 @@ typedef enum { @property(nonatomic, strong, nullable, setter = setAppInviteOneLink:) NSString * appInviteOneLinkID; /** - Opt-out tracking for specific user + Opt-out logging for specific user */ -@property(atomic) BOOL deviceTrackingDisabled; +@property(atomic) BOOL deviceLoggingDisabled; /** - Opt-out tracking for Apple Search Ads attributions + Opt-out for Apple Search Ads attributions */ -@property(atomic) BOOL disableIAdTracking; +@property(atomic) BOOL disableCollectASA; /** - AppsFlyer delegate. See `AppsFlyerTrackerDelegate` + AppsFlyer delegate. See `AppsFlyerLibDelegate` */ -@property(weak, nonatomic) id delegate; +@property(weak, nonatomic) id delegate; /** In app purchase receipt validation Apple environment(production or sandbox). The default value is NO @@ -296,36 +300,31 @@ typedef enum { */ @property(nonatomic) BOOL useUninstallSandbox; -/** - Advertising Id(exposed for RemoteDebug) - */ -@property(nonatomic, strong, readonly) NSString *advertiserId; - /** For advertisers who wrap OneLink within another Universal Link. - An advertiser will be able to deeplink from a OneLink wrapped within another Universal Link and also track this retargeting conversion. - + An advertiser will be able to deeplink from a OneLink wrapped within another Universal Link and also log this retargeting conversion. + Objective-C: - +
- [[AppsFlyerTracker sharedTracker] setResolveDeepLinkURLs:@[@"domain.com", @"subdomain.domain.com"]];
+ [[AppsFlyerLib shared] setResolveDeepLinkURLs:@[@"domain.com", @"subdomain.domain.com"]];
  
*/ @property(nonatomic, nullable) NSArray *resolveDeepLinkURLs; /** For advertisers who use vanity OneLinks. - + Objective-C: - +
- [[AppsFlyerTracker sharedTracker] oneLinkCustomDomains:@[@"domain.com", @"subdomain.domain.com"]];
+ [[AppsFlyerLib shared] oneLinkCustomDomains:@[@"domain.com", @"subdomain.domain.com"]];
  
*/ @property(nonatomic, nullable) NSArray *oneLinkCustomDomains; /* - * Set phone number for each `trackAppLaunch` event. `phoneNumber` will be sent as SHA256 string + * Set phone number for each `start` event. `phoneNumber` will be sent as SHA256 string */ @property(nonatomic, nullable) NSString *phoneNumber; @@ -335,94 +334,81 @@ typedef enum { To disable app's vendor identifier(IDFV), set disableIDFVCollection to true */ @property(nonatomic) BOOL disableIDFVCollection; - + /** 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. - + Objective-C: - +
- [[AppsFlyerTracker sharedTracker] enableFacebookDeferredApplinksWithClass:[FBSDKAppLinkUtility class]]
+ [[AppsFlyerLib shared] enableFacebookDeferredApplinksWithClass:[FBSDKAppLinkUtility class]]
  
- + Swift: - +
- AppsFlyerTracker.shared().enableFacebookDeferredApplinks(with: FBSDKAppLinkUtility.self)
+ AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: FBSDKAppLinkUtility.self)
  
- + @param facebookAppLinkUtilityClass requeries method call `[FBSDKAppLinkUtility class]` as param. */ - (void)enableFacebookDeferredApplinksWithClass:(Class _Nullable)facebookAppLinkUtilityClass; /** Use this to send the user's emails - + @param userEmails The list of strings that hold mails @param type Hash algoritm */ - (void)setUserEmails:(NSArray * _Nullable)userEmails withCryptType:(EmailCryptType)type; /** - Track application launch(session). + Start SDK session Add the following method at the `applicationDidBecomeActive` in AppDelegate class */ -- (void)trackAppLaunch; +- (void)start; -- (void)trackAppLaunchWithCompletionHandler:(void (^ _Nullable)(NSDictionary * _Nullable dictionary, NSError * _Nullable error))completionHandler; +- (void)startWithCompletionHandler:(void (^ _Nullable)(NSDictionary * _Nullable dictionary, NSError * _Nullable error))completionHandler; /** - Use this method to track events in your app like purchases or user actions - - @param eventName Contains name of event that could be provided from predefined constants in `AppsFlyerTracker.h` - @param value Contains value for handling by backend - -
- [[AppsFlyer sharedTracker] trackEvent:AFEventPurchase withValue:"200"];
- 
- - */ -- (void)trackEvent:(NSString *)eventName withValue:(NSString * _Nullable)value __attribute__((deprecated)); + Use this method to log an events with mulitple values. See AppsFlyer's documentation for details. -/** - Use this method to track an events with mulitple values. See AppsFlyer's documentation for details. - Objective-C: - +
- [[AppsFlyerTracker sharedTracker] trackEvent:AFEventPurchase
+ [[AppsFlyerLib shared] logEvent:AFEventPurchase
         withValues: @{AFEventParamRevenue  : @200,
                       AFEventParamCurrency : @"USD",
                       AFEventParamQuantity : @2,
                       AFEventParamContentId: @"092",
                       AFEventParamReceiptId: @"9277"}];
  
- + Swift: - +
- AppsFlyerTracker.shared().trackEvent(AFEventPurchase,
+ AppsFlyerLib.shared().logEvent(AFEventPurchase,
         withValues: [AFEventParamRevenue  : "1200",
                      AFEventParamContent  : "shoes",
                      AFEventParamContentId: "123"])
  
- - @param eventName Contains name of event that could be provided from predefined constants in `AppsFlyerTracker.h` + + @param eventName Contains name of event that could be provided from predefined constants in `AppsFlyerLib.h` @param values Contains dictionary of values for handling by backend */ -- (void)trackEvent:(NSString *)eventName withValues:(NSDictionary * _Nullable)values; +- (void)logEvent:(NSString *)eventName withValues:(NSDictionary * _Nullable)values; -- (void)trackEventWithEventName:(NSString *)eventName - eventValues:(NSDictionary * _Nullable)eventValues - completionHandler:(void (^ _Nullable)(NSDictionary * _Nullable dictionary, NSError * _Nullable error))completionHandler -NS_SWIFT_NAME(trackEvent(name:values:completionHandler:)); +- (void)logEventWithEventName:(NSString *)eventName + eventValues:(NSDictionary * _Nullable)eventValues + completionHandler:(void (^ _Nullable)(NSDictionary * _Nullable dictionary, NSError * _Nullable error))completionHandler +NS_SWIFT_NAME(logEvent(name:values:completionHandler:)); /** - To track and validate in app purchases you can call this method from the completeTransaction: method on + To log and validate in app purchases you can call this method from the completeTransaction: method on your `SKPaymentTransactionObserver`. - + @param productIdentifier The product identifier @param price The product price @param currency The product currency @@ -431,47 +417,47 @@ NS_SWIFT_NAME(trackEvent(name:values:completionHandler:)); @param successBlock The success callback @param failedBlock The failure callback */ -- (void)validateAndTrackInAppPurchase:(NSString * _Nullable)productIdentifier - price:(NSString * _Nullable)price - currency:(NSString * _Nullable)currency - transactionId:(NSString * _Nullable)tranactionId - additionalParameters:(NSDictionary * _Nullable)params - success:(void (^ _Nullable)(NSDictionary * response))successBlock - failure:(void (^ _Nullable)(NSError * _Nullable error, id _Nullable reponse))failedBlock NS_AVAILABLE(10_7, 7_0); +- (void)validateAndLogInAppPurchase:(NSString * _Nullable)productIdentifier + price:(NSString * _Nullable)price + currency:(NSString * _Nullable)currency + transactionId:(NSString * _Nullable)tranactionId + additionalParameters:(NSDictionary * _Nullable)params + success:(void (^ _Nullable)(NSDictionary * response))successBlock + failure:(void (^ _Nullable)(NSError * _Nullable error, id _Nullable reponse))failedBlock NS_AVAILABLE(10_7, 7_0); /** - To Track location for geo-fencing. Does the same as code below. - + To log location for geo-fencing. Does the same as code below. +
- AppsFlyerTracker.shared().trackEvent(AFEventLocation, withValues: [AFEventParamLong:longitude, AFEventParamLat:latitude])
+ AppsFlyerLib.shared().logEvent(AFEventLocation, withValues: [AFEventParamLong:longitude, AFEventParamLat:latitude])
  
- + @param longitude The location longitude @param latitude The location latitude */ -- (void)trackLocation:(double)longitude latitude:(double)latitude; +- (void)logLocationEvent:(double)longitude latitude:(double)latitude; /** This method returns AppsFlyer's internal id(unique for your app) - + @return Internal AppsFlyer Id */ - (NSString *)getAppsFlyerUID; /** - In case you want to track deep linking. Does the same as `-handleOpenURL:sourceApplication:withAnnotation`. - + In case you want to log deep linking. Does the same as `-handleOpenURL:sourceApplication:withAnnotation`. + @warning Prefered to use `-handleOpenURL:sourceApplication:withAnnotation`. - + @param url The URL that was passed to your AppDelegate. @param sourceApplication The sourceApplication that passed to your AppDelegate. */ - (void)handleOpenURL:(NSURL * _Nullable)url sourceApplication:(NSString * _Nullable)sourceApplication API_UNAVAILABLE(macos); /** - In case you want to track deep linking. + In case you want to log deep linking. Call this method from inside your AppDelegate `-application:openURL:sourceApplication:annotation:` - + @param url The URL that was passed to your AppDelegate. @param sourceApplication The sourceApplication that passed to your AppDelegate. @param annotation The annotation that passed to your app delegate. @@ -484,7 +470,7 @@ NS_SWIFT_NAME(trackEvent(name:values:completionHandler:)); Call this method from inside of your AppDelegate `-application:openURL:options:` method. This method is functionally the same as calling the AppsFlyer method `-handleOpenURL:sourceApplication:withAnnotation`. - + @param url The URL that was passed to your app delegate @param options The options dictionary that was passed to your AppDelegate. */ @@ -492,8 +478,8 @@ NS_SWIFT_NAME(trackEvent(name:values:completionHandler:)); /** Allow AppsFlyer to handle restoration from an NSUserActivity. - Use this method to track deep links with OneLink. - + Use this method to log deep links with OneLink. + @param userActivity The NSUserActivity that caused the app to be opened. */ - (BOOL)continueUserActivity:(NSUserActivity * _Nullable)userActivity @@ -501,11 +487,11 @@ NS_SWIFT_NAME(trackEvent(name:values:completionHandler:)); /** Enable AppsFlyer to handle a push notification. - + @see [Learn more here](https://support.appsflyer.com/hc/en-us/articles/207364076-Measuring-Push-Notification-Re-Engagement-Campaigns) - + @warning To make it work - set data, related to AppsFlyer under key @"af". - + @param pushPayload The `userInfo` from received remote notification. One of root keys should be @"af". */ - (void)handlePushNotification:(NSDictionary * _Nullable)pushPayload; @@ -513,14 +499,14 @@ NS_SWIFT_NAME(trackEvent(name:values:completionHandler:)); /** Register uninstall - you should register for remote notification and provide AppsFlyer the push device token. - + @param deviceToken The `deviceToken` from `-application:didRegisterForRemoteNotificationsWithDeviceToken:` */ - (void)registerUninstall:(NSData * _Nullable)deviceToken; /** Get SDK version. - + @return The AppsFlyer SDK version info. */ - (NSString *)getSDKVersion; @@ -530,22 +516,31 @@ NS_SWIFT_NAME(trackEvent(name:values:completionHandler:)); */ - (void)remoteDebuggingCallWithData:(NSString *)data; +/** + Used to force the trigger `onAppOpenAttribution` delegate. + Notice, re-engagement, session and launch won't be counted. + Only for OneLink/UniversalLink/Deeplink resolving. + + @param URL The param to resolve into -[AppsFlyerLibDelegate onAppOpenAttribution:] + */ +- (void)performOnAppAttributionWithURL:(NSURL * _Nullable)URL; + /** @brief This property accepts a string value representing the host name for all endpoints. Can be used to Zero rate your application’s data usage. Contact your CSM for more information. - + @warning To use `default` SDK endpoint – set value to `nil`. - + Objective-C: - +
- [[AppsFlyerTracker sharedTracker] setHost:@"example.com"];
+ [[AppsFlyerLib shared] setHost:@"example.com"];
  
- + Swift: - +
- AppsFlyerTracker.shared().host = "example.com"
+ AppsFlyerLib.shared().host = "example.com"
  
*/ @property(nonatomic, strong, readonly) NSString *host; @@ -569,16 +564,28 @@ NS_SWIFT_NAME(trackEvent(name:values:completionHandler:)); /** API to shut down all SDK activities. - + @warning This will disable all requests from AppsFlyer SDK. */ -@property(atomic) BOOL isStopTracking; +@property(atomic) BOOL isStopped; /** API to set manually Facebook deferred app link */ @property(nonatomic, nullable) NSURL *facebookDeferredAppLink; +/** + Block an events from being shared with ad networks and other 3rd party integrations + Must only include letters/digits or underscore, maximum length: 45 + */ +@property(nonatomic, nullable) NSArray *sharingFilter; + +/** + Block an events from being shared with any partner + This method overwrite -[AppsFlyerLib setSharingFilter:] + */ +-(void)setSharingFilterForAllPartners; + @end -NS_ASSUME_NONNULL_END +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/ios/AppsFlyerLinkGenerator.h b/ios/AppsFlyerLinkGenerator.h index b917074e..5347dba2 100644 --- a/ios/AppsFlyerLinkGenerator.h +++ b/ios/AppsFlyerLinkGenerator.h @@ -49,4 +49,4 @@ NS_ASSUME_NONNULL_BEGIN @end -NS_ASSUME_NONNULL_END +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/ios/AppsFlyerShareInviteHelper.h b/ios/AppsFlyerShareInviteHelper.h index 6bc25335..e7f8fc2a 100644 --- a/ios/AppsFlyerShareInviteHelper.h +++ b/ios/AppsFlyerShareInviteHelper.h @@ -25,11 +25,11 @@ NS_ASSUME_NONNULL_BEGIN + (void)generateInviteUrlWithLinkGenerator:(AppsFlyerLinkGenerator *(^)(AppsFlyerLinkGenerator *generator))generatorCreator completionHandler:(void (^)(NSURL *_Nullable url))completionHandler; /** - * It is recommended to generate an in-app event after the invite is sent to track the invites from the senders' perspective. + * It is recommended to generate an in-app event after the invite is sent to log the invites from the senders' perspective. * This enables you to find the users that tend most to invite friends, and the media sources that get you these users. */ -+ (void)trackInvite:(nullable NSString *)channel parameters:(nullable NSDictionary *)parameters; ++ (void)logInvite:(nullable NSString *)channel parameters:(nullable NSDictionary *)parameters; @end -NS_ASSUME_NONNULL_END +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/ios/RNAppsFlyer.h b/ios/RNAppsFlyer.h index e3718bdd..931f0ce8 100755 --- a/ios/RNAppsFlyer.h +++ b/ios/RNAppsFlyer.h @@ -19,6 +19,7 @@ static NSString *const NO_APPID_FOUND = @"No 'appId' found or its static NSString *const NO_EVENT_NAME_FOUND = @"No 'eventName' found or its empty"; static NSString *const EMPTY_OR_CORRUPTED_LIST = @"No arguments found or list is corrupted"; static NSString *const SUCCESS = @"Success"; +static NSString *const IOS_14_ONLY = @"Feature only supported on iOS 14 and above"; // Appsflyer JS objects #define afDevKey @"devKey" diff --git a/ios/RNAppsFlyer.m b/ios/RNAppsFlyer.m index 72736bd0..cc41c73c 100755 --- a/ios/RNAppsFlyer.m +++ b/ios/RNAppsFlyer.m @@ -1,13 +1,14 @@ #import "RNAppsFlyer.h" -#if __has_include() // from Pod -#import +#if __has_include() // from Pod +#import #else -#import "AppsFlyerTracker.h" +#import "AppsFlyerLib.h" #endif +#import -@interface RNAppsFlyer() +@interface RNAppsFlyer() @end @@ -17,6 +18,48 @@ @implementation RNAppsFlyer RCT_EXPORT_MODULE() +RCT_EXPORT_METHOD(waitForAdvertisingIdentifierWithTimeoutInterval:(NSTimeInterval)timeoutInterval + successCallback :(RCTResponseSenderBlock)successCallback + errorCallback:(RCTResponseErrorBlock)errorCallback) { + if (@available(iOS 14, *)) { + [[AppsFlyerLib shared] waitForAdvertisingIdentifierWithTimeoutInterval:timeoutInterval]; + successCallback(@[SUCCESS]); + } else { + NSError* error = [NSError errorWithDomain:IOS_14_ONLY code:0 userInfo:nil]; + errorCallback(error); + } +} + +RCT_EXPORT_METHOD(requestTrackingAuthorizationWith:(RCTResponseSenderBlock)successCallback + errorCallback:(RCTResponseErrorBlock)errorCallback){ + if (@available(iOS 14, *)) { + [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { + NSString* statusDescription; + switch (status) { + case ATTrackingManagerAuthorizationStatusDenied: + statusDescription = @"Denied"; + break; + case ATTrackingManagerAuthorizationStatusAuthorized: + statusDescription = @"Authorized"; + break; + case ATTrackingManagerAuthorizationStatusRestricted: + statusDescription = @"Restricted"; + break; + case ATTrackingManagerAuthorizationStatusNotDetermined: + statusDescription = @"NotDetermined"; + break; + default: + statusDescription = @"Unknown (please report an issue to AppsFlyer github if you get this)"; + break; + } + successCallback(@[statusDescription]); + }]; + } else { + NSError* error = [NSError errorWithDomain:IOS_14_ONLY code:0 userInfo:nil]; + errorCallback(error); + } +} + RCT_EXPORT_METHOD(initSdk: (NSDictionary*)initSdkOptions successCallback :(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseErrorBlock)errorCallback) { @@ -40,18 +83,18 @@ @implementation RNAppsFlyer if(error) { reject([NSString stringWithFormat: @"%ld", (long)error.code], error.domain, error); } else { - resolve(@[SUCCESS]); + resolve(@[SUCCESS]); } } RCT_EXPORT_METHOD(trackAppLaunch) { - [[AppsFlyerTracker sharedTracker] trackAppLaunch]; + [[AppsFlyerLib shared] start]; } RCT_EXPORT_METHOD(trackEvent: (NSString *)eventName eventValues:(NSDictionary *)eventValues successCallback :(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseErrorBlock)errorCallback) { - NSError *error = [self trackEventInternal:eventName eventValues:eventValues]; + NSError *error = [self logEventInternal:eventName eventValues:eventValues]; if(error) { errorCallback(error); @@ -65,34 +108,34 @@ @implementation RNAppsFlyer trackEventWithPromiseWithResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { - NSError *error = [self trackEventInternal:eventName eventValues:eventValues]; + NSError *error = [self logEventInternal:eventName eventValues:eventValues]; if(error){ reject([NSString stringWithFormat: @"%ld", (long)error.code], error.domain, error); } else{ - //TODO wait callback from SDK + //TODO wait callback from SDK resolve(@[SUCCESS]); } } RCT_EXPORT_METHOD(getAppsFlyerUID: (RCTResponseSenderBlock)callback) { - NSString *uid = [[AppsFlyerTracker sharedTracker] getAppsFlyerUID]; + NSString *uid = [[AppsFlyerLib shared] getAppsFlyerUID]; callback(@[[NSNull null], uid]); } RCT_EXPORT_METHOD(setCustomerUserId: (NSString *)userId callback:(RCTResponseSenderBlock)callback) { - [[AppsFlyerTracker sharedTracker] setCustomerUserID:userId]; + [[AppsFlyerLib shared] setCustomerUserID:userId]; callback(@[SUCCESS]); } RCT_EXPORT_METHOD(stopTracking: (BOOL)isStopTracking callback:(RCTResponseSenderBlock)callback) { - [AppsFlyerTracker sharedTracker].isStopTracking = isStopTracking; + [AppsFlyerLib shared].isStopped = isStopTracking; callback(@[SUCCESS]); } RCT_EXPORT_METHOD(trackLocation: (double)longitude latitude:(double)latitude callback:(RCTResponseSenderBlock)callback) { - [[AppsFlyerTracker sharedTracker] trackLocation:longitude latitude:latitude]; + [[AppsFlyerLib shared] logLocationEvent:longitude latitude:latitude]; NSArray *events = @[[NSNumber numberWithDouble:longitude], [NSNumber numberWithDouble:latitude]]; callback(@[[NSNull null], events]); } @@ -138,12 +181,12 @@ @implementation RNAppsFlyer errorCallback(error); } else{ - [[AppsFlyerTracker sharedTracker] setUserEmails:emails withCryptType:emailsCryptType]; + [[AppsFlyerLib shared] setUserEmails:emails withCryptType:emailsCryptType]; successCallback(@[SUCCESS]); } } - -(NSError *) callSdkInternal:(NSDictionary*)initSdkOptions { +-(NSError *) callSdkInternal:(NSDictionary*)initSdkOptions { NSString* devKey = nil; NSString* appId = nil; @@ -184,52 +227,52 @@ -(NSError *) callSdkInternal:(NSDictionary*)initSdkOptions { } else{ if(isConversionData == YES){ - [AppsFlyerTracker sharedTracker].delegate = self; + [AppsFlyerLib shared].delegate = self; } - [AppsFlyerTracker sharedTracker].appleAppID = appId; - [AppsFlyerTracker sharedTracker].appsFlyerDevKey = devKey; - [AppsFlyerTracker sharedTracker].isDebug = isDebug; - [[AppsFlyerTracker sharedTracker] trackAppLaunch]; + [AppsFlyerLib shared].appleAppID = appId; + [AppsFlyerLib shared].appsFlyerDevKey = devKey; + [AppsFlyerLib shared].isDebug = isDebug; + [[AppsFlyerLib shared] start]; // Register for background-foreground transitions natively instead of doing this in JavaScript [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(sendLaunch:) - name:UIApplicationDidBecomeActiveNotification - object:nil]; + selector:@selector(sendLaunch:) + name:UIApplicationDidBecomeActiveNotification + object:nil]; return nil; } } -(void)sendLaunch:(UIApplication *)application { - [[AppsFlyerTracker sharedTracker] trackAppLaunch]; + [[AppsFlyerLib shared] start]; } --(NSError *) trackEventInternal: (NSString *)eventName eventValues:(NSDictionary *)eventValues { +-(NSError *) logEventInternal: (NSString *)eventName eventValues:(NSDictionary *)eventValues { if (!eventName || [eventName isEqualToString:@""]) { NSError *error = [NSError errorWithDomain:NO_EVENT_NAME_FOUND code:2 userInfo:nil]; return error; } - [[AppsFlyerTracker sharedTracker] trackEvent:eventName withValues:eventValues]; + [[AppsFlyerLib shared] logEvent:eventName withValues:eventValues]; return nil; } RCT_EXPORT_METHOD(setAdditionalData: (NSDictionary *)additionalData callback:(RCTResponseSenderBlock)callback) { - [[AppsFlyerTracker sharedTracker] setAdditionalData:additionalData]; + [[AppsFlyerLib shared] setAdditionalData:additionalData]; callback(@[SUCCESS]); } //USER INVITES RCT_EXPORT_METHOD(setAppInviteOneLinkID: (NSString *)oneLinkID callback:(RCTResponseSenderBlock)callback) { - [AppsFlyerTracker sharedTracker].appInviteOneLinkID = oneLinkID; + [AppsFlyerLib shared].appInviteOneLinkID = oneLinkID; callback(@[SUCCESS]); } RCT_EXPORT_METHOD(setCurrencyCode: (NSString *)currencyCode callback:(RCTResponseSenderBlock)callback) { - [[AppsFlyerTracker sharedTracker] setCurrencyCode:currencyCode]; + [[AppsFlyerLib shared] setCurrencyCode:currencyCode]; callback(@[SUCCESS]); } @@ -270,9 +313,9 @@ -(NSError *) trackEventInternal: (NSString *)eventName eventValues:(NSDictionary } //CROSS PROMOTION -RCT_EXPORT_METHOD(trackCrossPromotionImpression: (NSString *)appId campaign:(NSString *)campaign) { +RCT_EXPORT_METHOD(trackCrossPromotionImpression: (NSString *)appId campaign:(NSString *)campaign parameters:(NSDictionary *)parameters) { if (appId != nil && ![appId isEqualToString:@""]) { - [AppsFlyerCrossPromotionHelper trackCrossPromoteImpression:appId campaign:campaign]; + [AppsFlyerCrossPromotionHelper logCrossPromoteImpression:appId campaign:campaign parameters:parameters]; } } @@ -302,10 +345,10 @@ -(NSError *) trackEventInternal: (NSString *)eventName eventValues:(NSDictionary -(void)onConversionDataSuccess:(NSDictionary*) installData { NSDictionary* message = @{ - @"status": afSuccess, - @"type": afOnInstallConversionDataLoaded, - @"data": [installData copy] - }; + @"status": afSuccess, + @"type": afOnInstallConversionDataLoaded, + @"data": [installData copy] + }; [self performSelectorOnMainThread:@selector(handleCallback:) withObject:message waitUntilDone:NO]; @@ -315,10 +358,10 @@ -(void)onConversionDataSuccess:(NSDictionary*) installData { -(void)onConversionDataFail:(NSError *) _errorMessage { NSDictionary* errorMessage = @{ - @"status": afFailure, - @"type": afOnInstallConversionFailure, - @"data": _errorMessage.localizedDescription - }; + @"status": afFailure, + @"type": afOnInstallConversionFailure, + @"data": _errorMessage.localizedDescription + }; [self performSelectorOnMainThread:@selector(handleCallback:) withObject:errorMessage waitUntilDone:NO]; @@ -328,10 +371,10 @@ -(void)onConversionDataFail:(NSError *) _errorMessage { - (void) onAppOpenAttribution:(NSDictionary*) attributionData { NSDictionary* message = @{ - @"status": afSuccess, - @"type": afOnAppOpenAttribution, - @"data": attributionData - }; + @"status": afSuccess, + @"type": afOnAppOpenAttribution, + @"data": attributionData + }; [self performSelectorOnMainThread:@selector(handleCallback:) withObject:message waitUntilDone:NO]; } @@ -339,10 +382,10 @@ - (void) onAppOpenAttribution:(NSDictionary*) attributionData { - (void) onAppOpenAttributionFailure:(NSError *)_errorMessage { NSDictionary* errorMessage = @{ - @"status": afFailure, - @"type": afOnAttributionFailure, - @"data": _errorMessage.localizedDescription - }; + @"status": afFailure, + @"type": afOnAttributionFailure, + @"data": _errorMessage.localizedDescription + }; [self performSelectorOnMainThread:@selector(handleCallback:) withObject:errorMessage waitUntilDone:NO]; } @@ -395,7 +438,7 @@ -(void) reportOnSuccess:(NSString *)data type:(NSString*) type { } RCT_EXPORT_METHOD(setDeviceTrackingDisabled: (BOOL *)b callback:(RCTResponseSenderBlock)callback) { - [[AppsFlyerTracker sharedTracker] setDeviceTrackingDisabled:b]; + [[AppsFlyerLib shared] setDeviceLoggingDisabled:b]; callback(@[SUCCESS]); } @@ -411,39 +454,39 @@ -(void) reportOnSuccess:(NSString *)data type:(NSString*) type { whole_byte = strtol(byte_chars, NULL, 16); [deviceTokenData appendBytes:&whole_byte length:1]; } - [[AppsFlyerTracker sharedTracker] registerUninstall:deviceTokenData]; + [[AppsFlyerLib shared] registerUninstall:deviceTokenData]; callback(@[SUCCESS]); } RCT_EXPORT_METHOD(setOneLinkCustomDomains:(NSArray *) domains - successCallback :(RCTResponseSenderBlock)successCallback - errorCallback:(RCTResponseErrorBlock)errorCallback) { - [[AppsFlyerTracker sharedTracker] setOneLinkCustomDomains:domains]; + successCallback :(RCTResponseSenderBlock)successCallback + errorCallback:(RCTResponseErrorBlock)errorCallback) { + [[AppsFlyerLib shared] setOneLinkCustomDomains:domains]; successCallback(@[SUCCESS]); } RCT_EXPORT_METHOD(setResolveDeepLinkURLs:(NSArray *) urls - successCallback :(RCTResponseSenderBlock)successCallback - errorCallback:(RCTResponseErrorBlock)errorCallback) { - [[AppsFlyerTracker sharedTracker] setResolveDeepLinkURLs:urls]; + successCallback :(RCTResponseSenderBlock)successCallback + errorCallback:(RCTResponseErrorBlock)errorCallback) { + [[AppsFlyerLib shared] setResolveDeepLinkURLs:urls]; successCallback(@[SUCCESS]); } RCT_EXPORT_METHOD(performOnAppAttribution:(NSString *) urlString - callback :(RCTResponseSenderBlock)callback) { + callback :(RCTResponseSenderBlock)callback) { NSURL *url = [NSURL URLWithString:urlString]; - [[AppsFlyerTracker sharedTracker] performOnAppAttributionWithURL:url]; + [[AppsFlyerLib shared] performOnAppAttributionWithURL:url]; callback(@[SUCCESS]); } RCT_EXPORT_METHOD(setSharingFilterForAllPartners) { - [[AppsFlyerTracker sharedTracker] setSharingFilterForAllPartners]; + [[AppsFlyerLib shared] setSharingFilterForAllPartners]; } RCT_EXPORT_METHOD(setSharingFilter:(NSArray *)partners - successCallback:(RCTResponseSenderBlock)successCallback - errorCallback:(RCTResponseErrorBlock)errorCallback) { - [[AppsFlyerTracker sharedTracker] setSharingFilter:partners]; + successCallback:(RCTResponseSenderBlock)successCallback + errorCallback:(RCTResponseErrorBlock)errorCallback) { + [[AppsFlyerLib shared] setSharingFilter:partners]; successCallback(@[SUCCESS]); } diff --git a/react-native-appsflyer.podspec b/react-native-appsflyer.podspec index e45b3de2..a662e8f5 100644 --- a/react-native-appsflyer.podspec +++ b/react-native-appsflyer.podspec @@ -13,6 +13,6 @@ Pod::Spec.new do |s| s.source_files = 'ios/**/*.{h,m}' s.platform = :ios, "8.0" s.static_framework = true - s.dependency 'AppsFlyerFramework', '~> 5.4.1' + s.dependency 'Beta-AppsFlyerFramework', '~> 6.0.0' s.dependency 'React' end From b899c28f2d8ab619c02aec041f0cb776614fc1a4 Mon Sep 17 00:00:00 2001 From: Vitaly Sokolov Date: Mon, 10 Aug 2020 14:56:58 +0300 Subject: [PATCH 02/33] rename public APIs, remove deprecated APIs --- .../appsflyer-issue-template.md | 2 +- Docs/API.md | 42 ++++++------ Docs/Guides.md | 34 +++++----- README.md | 4 +- .../reactnative/RNAppsFlyerModule.java | 61 +++++------------ index.d.ts | 26 +++---- index.js | 67 +++++++------------ ios/RNAppsFlyer.m | 66 +++++------------- 8 files changed, 105 insertions(+), 197 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/appsflyer-issue-template.md b/.github/ISSUE_TEMPLATE/appsflyer-issue-template.md index 76ca3779..292a8661 100644 --- a/.github/ISSUE_TEMPLATE/appsflyer-issue-template.md +++ b/.github/ISSUE_TEMPLATE/appsflyer-issue-template.md @@ -33,7 +33,7 @@ e.g. Run `pod install` ## What did you expect to happen? ℹ Please replace these two lines with what you expected to happen. -e.g. Event to be tracked +e.g. Event to be logged ## What happened instead? diff --git a/Docs/API.md b/Docs/API.md index 5500ef5f..ebbc5a97 100755 --- a/Docs/API.md +++ b/Docs/API.md @@ -4,11 +4,11 @@ - [initSdk](#initSdk) - [onInstallConversionData](#onInstallConversionData) - [onAppOpenAttribution](#onAppOpenAttribution) -- [trackEvent](#trackEvent) +- [logEvent](#logEvent) - [setCustomerUserId](#setCustomerUserId) - [getAppsFlyerUID](#getAppsFlyerUID) -- [stopTracking](#stopTracking) -- [trackLocation](#trackLocation) +- [stop](#stop) +- [logLocation](#logLocation) - [setUserEmails](#setUserEmails) - [setAdditionalData](#setAdditionalData) - [sendDeepLinkData](#sendDeepLinkData) @@ -17,10 +17,10 @@ - [setCollectAndroidID](#setCollectAndroidID) - [setAppInviteOneLinkID](#setAppInviteOneLinkID) - [generateInviteLink](#generateInviteLink) -- [trackCrossPromotionImpression](#trackCrossPromotionImpression) -- [trackAndOpenStore](#trackAndOpenStore) +- [logCrossPromotionImpression](#logCrossPromotionImpression) +- [logAndOpenStore](#logAndOpenStore) - [setCurrencyCode](#setCurrencyCode) -- [setDeviceTrackingDisabled](#setDeviceTrackingDisabled) +- [setDeviceLoggingDisabled](#setDeviceLoggingDisabled) - [setOneLinkCustomDomains](#setOneLinkCustomDomains) - [setResolveDeepLinkURLs](#setResolveDeepLinkURLs) - [performOnAppAttribution](#performOnAppAttribution) @@ -169,7 +169,7 @@ appsFlyer.initSdk(/*...*/); --- -##### **`trackEvent(eventName, eventValues, success, error)`** +##### **`logEvent(eventName, eventValues, success, error)`** In-App Events provide insight on what is happening in your app. It is recommended to take the time and define the events you want to measure to allow you to measure ROI (Return on Investment) and LTV (Lifetime Value). @@ -194,7 +194,7 @@ const eventValues = { af_revenue: '2', }; -appsFlyer.trackEvent( +appsFlyer.logEvent( eventName, eventValues, (res) => { @@ -253,7 +253,7 @@ appsFlyer.getAppsFlyerUID((err, appsFlyerUID) => { --- -##### **`stopTracking(isStopTracking, callback)`** +##### **`stop(isStopped, callback)`** In some extreme cases you might want to shut down all SDK functions due to legal and privacy compliance. This can be achieved with the stopSDK API. Once this API is invoked, our SDK no longer communicates with our servers and stops functioning. @@ -263,21 +263,21 @@ In any event, the SDK can be reactivated by calling the same API, by passing fal | parameter | type | description | | ---------- |----------|------------------ | -| isStopTracking | boolean | True if the SDK is stopped (default value is false). | +| isStopped | boolean | True if the SDK is stopped (default value is false). | | callback | function | success callback | *Example:* ```javascript -appsFlyer.stopTracking(true, (res) => { +appsFlyer.stop(true, (res) => { //... }); ``` --- -##### **`trackLocation(longitude, latitude, callback)`** +##### **`logLocation(longitude, latitude, callback)`** Manually record the location of the user. @@ -294,7 +294,7 @@ Manually record the location of the user. const latitude = -18.406655; const longitude = 46.40625; -appsFlyer.trackLocation(longitude, latitude, (err, coords) => { +appsFlyer.logLocation(longitude, latitude, (err, coords) => { if (err) { console.error(err); } else { @@ -529,7 +529,7 @@ A complete list of supported parameters is available [here](https://support.apps --- -##### **`trackCrossPromotionImpression(appId, campaign)`** +##### **`logCrossPromotionImpression(appId, campaign)`** To attribute an impression use the following API call.
Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard. @@ -544,14 +544,14 @@ Make sure to use the promoted App ID as it appears within the AppsFlyer dashboar *Example:* ```javascript -appsFlyer.trackCrossPromotionImpression("com.myandroid.app", "myCampaign"); +appsFlyer.logCrossPromotionImpression("com.myandroid.app", "myCampaign"); ``` -For more details about Cross-Promotion tracking please see the relevent doc [here](https://support.appsflyer.com/hc/en-us/articles/115004481946-Cross-Promotion-Tracking). +For more details about Cross-Promotion logging please see the relevent doc [here](https://support.appsflyer.com/hc/en-us/articles/115004481946-Cross-Promotion-Tracking). --- -#####
**`trackAndOpenStore(appId, campaign, params)`** +##### **`logAndOpenStore(appId, campaign, params)`** Use the following API to attribute the click and launch the app store's app page. @@ -570,7 +570,7 @@ var crossPromOptions = { myCustomParameter: 'newUser', }; -appsFlyer.trackAndOpenStore( +appsFlyer.logAndOpenStore( 'com.myandroid.app', 'myCampaign', crossPromOptions @@ -599,7 +599,7 @@ appsFlyer.setCurrencyCode(currencyCode, () => {}); --- -##### **`setDeviceTrackingDisabled(isDeviceTrackingDisabled, callback)`** +##### **`setDeviceLoggingDisabled(isDeviceLoggingDisabled, callback)`** 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.
@@ -607,14 +607,14 @@ To anonymize an app user:
| parameter | type | description | | ---------- |----------|------------------ | -| isDeviceTrackingDisabled | boolean | True if want Anonymize user Data (default value is false). | +| isDeviceLoggingDisabled | boolean | True if want Anonymize user Data (default value is false). | | callback | function | success callback | *Example:* ```javascript -appsFlyer.setDeviceTrackingDisabled(true, () => {}); +appsFlyer.setDeviceLoggingDisabled(true, () => {}); ``` --- diff --git a/Docs/Guides.md b/Docs/Guides.md index 4f36e381..d7e01c45 100755 --- a/Docs/Guides.md +++ b/Docs/Guides.md @@ -10,9 +10,9 @@ - [Direct Deep Linking](#direct-deep-linking) - [iOS Deeplink Setup](#iosdeeplinks) - [Android Deeplink Setup](#android-deeplinks) -- [Uninstall](#track-app-uninstalls) - - [iOS Uninstall Setup](#track-app-uninstalls-ios) - - [Android Uninstall Setup](#track-app-uninstalls-android) +- [Uninstall](#measure-app-uninstalls) + - [iOS Uninstall Setup](#measure-app-uninstalls-ios) + - [Android Uninstall Setup](#measure-app-uninstalls-android) ##
Init SDK @@ -236,22 +236,22 @@ const Home = (props) => { ### iOS Deep Links - Universal Links and URL Schemes -In order to track retargeting and use the onAppOpenAttribution callbacks in iOS, the developer needs to pass the User Activity / URL to our SDK, via the following methods in the **AppDelegate.m** file: +In order to record retargeting and use the onAppOpenAttribution callbacks in iOS, the developer needs to pass the User Activity / URL to our SDK, via the following methods in the **AppDelegate.m** file: #### import ```objectivec #import -#if __has_include() // from Pod -#import +#if __has_include() // from Pod +#import #else -#import "AppsFlyerTracker.h" +#import "AppsFlyerLib.h" #endif ``` #### Universal Links (iOS 9 +) ```objectivec - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler { - [[AppsFlyerTracker sharedTracker] continueUserActivity:userActivity restorationHandler:restorationHandler]; + [[AppsFlyerLib shared] continueUserActivity:userActivity restorationHandler:restorationHandler]; return YES; } ``` @@ -260,14 +260,14 @@ In order to track retargeting and use the onAppOpenAttribution callbacks in iOS, ```objectivec // Reports app open from deep link from apps which do not support Universal Links (Twitter) and for iOS8 and below - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation { -[[AppsFlyerTracker sharedTracker] handleOpenURL:url sourceApplication:sourceApplication withAnnotation:annotation]; + [[AppsFlyerLib shared] handleOpenURL:url sourceApplication:sourceApplication withAnnotation:annotation]; return YES; } // Reports app open from URL Scheme deep link for iOS 10 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *) options { -[[AppsFlyerTracker sharedTracker] handleOpenUrl:url options:options]; + [[AppsFlyerLib shared] handleOpenUrl:url options:options]; return YES; } ``` @@ -294,13 +294,13 @@ This method makes sure that you get the latest deep link data even if the app wa --- -### Track App Uninstalls +### Measure App Uninstalls -#### iOS +#### iOS #### First method -AppsFlyer enables you to track app uninstalls. To handle notifications it requires to modify your `AppDelegate.m`. Use [didRegisterForRemoteNotificationsWithDeviceToken](https://developer.apple.com/reference/uikit/uiapplicationdelegate) to register to the uninstall feature. +AppsFlyer enables you to measure app uninstalls. To handle notifications it requires to modify your `AppDelegate.m`. Use [didRegisterForRemoteNotificationsWithDeviceToken](https://developer.apple.com/reference/uikit/uiapplicationdelegate) to register to the uninstall feature. *Example:* @@ -310,8 +310,8 @@ AppsFlyer enables you to track app uninstalls. To handle notifications it requir ... - (void)application:(UIApplication ​*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *​)deviceToken { -// notify AppsFlyerTracker -[[AppsFlyerTracker sharedTracker] registerUninstall:deviceToken]; +// notify AppsFlyerLib + [[AppsFlyerLib shared] registerUninstall:deviceToken]; } ``` @@ -329,7 +329,7 @@ appsFlyer.updateServerUninstallToken(deviceToken, (success) => { }); ``` -#### Android +#### Android Update Firebase device token so it can be sent to AppsFlyer @@ -341,5 +341,5 @@ appsFlyer.updateServerUninstallToken(newFirebaseToken, (success) => { }); ``` -Read more about Android Uninstall Tracking: [Appsflyer SDK support site](https://support.appsflyer.com/hc/en-us/articles/208004986-Android-Uninstall-Tracking) +Read more about Android Uninstall Measurement: [Appsflyer SDK support site](https://support.appsflyer.com/hc/en-us/articles/208004986-Android-Uninstall-Tracking) diff --git a/README.md b/README.md index 5d45199d..074cff94 100755 --- a/README.md +++ b/README.md @@ -76,14 +76,12 @@ appsFlyer.initSdk( | isDebug | Debug mode - set to `true` for testing only | -**Important** - For iOS another step is required. AppState logic is required to record Background-to-foreground transitions. Check out the [relevant guide](./Docs/API.md#--appsflyertrackapplaunch-void) to see how this mandatory step is implemented. - ## 📖 Guides Great installation and setup guides can be viewed [here](/Docs/Guides.md). - [init SDK Guide](/Docs/Guides.md#init-sdk) - [Deeplinking Guide](/Docs/Guides.md#deeplinking) -- [Uninstall Guide](/Docs/Guides.md#track-app-uninstalls) +- [Uninstall Guide](/Docs/Guides.md#measure-app-uninstalls) diff --git a/android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerModule.java b/android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerModule.java index 74b4fa11..37e8a690 100755 --- a/android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerModule.java +++ b/android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerModule.java @@ -126,7 +126,7 @@ private String callSdkInternal(ReadableMap _options) { isConversionData = options.optBoolean(afConversionData, false); if (isDebug == true) { - Log.d("AppsFlyer", "Starting Tracking"); + Log.d("AppsFlyer", "Starting SDK"); } instance.init( @@ -228,13 +228,7 @@ private void sendEvent(ReactContext reactContext, }; } - private void trackAppLaunch() { - Context c = application.getApplicationContext(); - AppsFlyerLib.getInstance().trackEvent(c, null, null); - } - - - private String trackEventInternal(final String eventName, ReadableMap eventData) { + private String logEventInternal(final String eventName, ReadableMap eventData) { if (eventName.trim().equals("")) { return NO_EVENT_NAME_FOUND; @@ -256,12 +250,12 @@ private String trackEventInternal(final String eventName, ReadableMap eventData) } @ReactMethod - public void trackEvent( + public void logEvent( final String eventName, ReadableMap eventData, Callback successCallback, Callback errorCallback) { try { - final String errorReason = trackEventInternal(eventName, eventData); + final String errorReason = logEventInternal(eventName, eventData); if (errorReason != null) { errorCallback.invoke(new Exception(errorReason).getMessage()); @@ -276,10 +270,10 @@ public void trackEvent( } @ReactMethod - public void trackEventWithPromise( + public void logEventWithPromise( final String eventName, ReadableMap eventData, Promise promise) { try { - final String errorReason = trackEventInternal(eventName, eventData); + final String errorReason = logEventInternal(eventName, eventData); if (errorReason != null) { promise.reject(errorReason, new Exception(errorReason).getMessage()); @@ -310,41 +304,12 @@ public void sendDeepLinkData(String url) { } } - @Deprecated - @ReactMethod - public void sendTrackingWithEvent(final String eventName) { - AppsFlyerLib.getInstance().trackEvent(getReactApplicationContext(), eventName, null); - } - @ReactMethod public void getAppsFlyerUID(Callback callback) { String appId = AppsFlyerLib.getInstance().getAppsFlyerUID(getReactApplicationContext()); callback.invoke(null, appId); } - /** - Deprecated - please use updateServerUninstallToken - */ - @ReactMethod - @Deprecated - public void setGCMProjectNumber(final String gcmProjectNumber, - Callback successCallback, - Callback errorCallback) { - // AppsFlyerLib.getInstance().setGCMProjectNumber(gcmProjectNumber); - errorCallback.invoke("Deprecated - please use updateServerUninstallToken"); - } - - /** - Deprecated - please use updateServerUninstallToken - */ - @ReactMethod - @Deprecated - public void enableUninstallTracking(final String gcmProjectNumber, - Callback successCallback) { - //AppsFlyerLib.getInstance().enableUninstallTracking(gcmProjectNumber); - successCallback.invoke("Deprecated - please use updateServerUninstallToken"); - } - @ReactMethod public void updateServerUninstallToken(final String token, Callback callback) { AppsFlyerLib.getInstance().updateServerUninstallToken(getReactApplicationContext(), token); @@ -370,7 +335,7 @@ public void setCollectAndroidID(boolean isCollect, Callback callback) { } @ReactMethod - public void stopTracking(boolean isCollect, Callback callback) { + public void stop(boolean isStopped, Callback callback) { AppsFlyerLib.getInstance().stopTracking(isCollect, getReactApplicationContext()); callback.invoke(SUCCESS); } @@ -531,14 +496,14 @@ public void onResponseError(final String error) { } @ReactMethod - public void trackCrossPromotionImpression(final String appId, final String campaign) { + public void logCrossPromotionImpression(final String appId, final String campaign) { if (appId != "" && campaign != "") { CrossPromotionHelper.trackCrossPromoteImpression(getReactApplicationContext(), appId, campaign); } } @ReactMethod - public void trackAndOpenStore(final String appId, final String campaign, ReadableMap params) { + public void logAndOpenStore(final String appId, final String campaign, ReadableMap params) { if (appId == null || appId == "") { return; @@ -557,7 +522,7 @@ public void trackAndOpenStore(final String appId, final String campaign, Readabl } @ReactMethod - public void setDeviceTrackingDisabled(boolean b, Callback callback){ + public void setDeviceLoggingDisabled(boolean b, Callback callback){ AppsFlyerLib.getInstance().setDeviceTrackingDisabled(b); callback.invoke(SUCCESS); } @@ -630,4 +595,10 @@ public void setSharingFilter(ReadableArray partnersArray, Callback successCallba errorCallback.invoke(EMPTY_OR_CORRUPTED_LIST); } } + + @ReactMethod + public void logLocation(double longitude, double latitude, Callback successCallback) { + AppsFlyerLib.getInstance().setSharingFilterForAllPartners(getReactApplicationContext(), latitude, longitude); + successCallback.invoke(SUCCESS, longitude, latitude); + } } diff --git a/index.d.ts b/index.d.ts index 826b07fe..59c0be22 100644 --- a/index.d.ts +++ b/index.d.ts @@ -51,32 +51,26 @@ declare module "react-native-appsflyer" { onInstallConversionFailure(callback:(data:ConversionData)=>any): () => void; onAppOpenAttribution(callback:(data:any)=>any): () => void; - initSdk(options:InitSDKOptions, successC?:SuccessCB, errorC?:ErrorCB): Response - trackEvent(eventName:string, eventValues:object, successC?:SuccessCB, errorC?:ErrorCB): Response - setUserEmails(options:SetEmailsOptions, successC?:SuccessCB, errorC?:ErrorCB): void + initSdk(options: InitSDKOptions, successC?: SuccessCB, errorC?: ErrorCB): Response + logEvent(eventName: string, eventValues: object, successC?: SuccessCB, errorC?: ErrorCB): Response + setUserEmails(options: SetEmailsOptions, successC?: SuccessCB, errorC?: ErrorCB): void setAdditionalData(additionalData: object, successC?: SuccessCB): void getAppsFlyerUID(callback: (error: Error, uid: string) => any): void setCustomerUserId(userId: string, successC?: SuccessCB): void - stopTracking(isStopTracking: boolean, successC?: SuccessCB): void + stop(isStopped: boolean, successC?: SuccessCB): void setAppInviteOneLinkID(oneLinkID: string, successC?: SuccessCB): void generateInviteLink(params: GenerateInviteLinkParams, successC?: SuccessCB, errorC?: ErrorCB): void - trackCrossPromotionImpression(appId: string, campaign: string, parameters: object): void - trackAndOpenStore(appId: string, campaign: string, params: object): void + logCrossPromotionImpression(appId: string, campaign: string, parameters: object): void + logAndOpenStore(appId: string, campaign: string, params: object): void setCurrencyCode(currencyCode: string, successC: SuccessCB): void - setDeviceTrackingDisabled(isDeviceTrackingDisabled: boolean, successC: SuccessCB): void + setDeviceLoggingDisabled(isDeviceLoggingDisabled: boolean, successC: SuccessCB): void setOneLinkCustomDomains(domains: string[], successC?: SuccessCB, errorC?: ErrorCB): void setResolveDeepLinkURLs(urls: string[], successC?: SuccessCB, errorC?: ErrorCB): void performOnAppAttribution(urlString, callback): void setSharingFilterForAllPartners(): void setSharingFilter(partners, successC, errorC): void - - /** - * For iOS Only - * */ - trackAppLaunch(): void - trackLocation(longitude: number, latitude: number, callback: SuccessCB): void + logLocation(longitude: number, latitude: number, callback: SuccessCB): void waitForAdvertisingIdentifierWithTimeoutInterval(timeoutInterval: number, successC?: SuccessCB, errorC?: ErrorCB): void - requestTrackingAuthorization(successC, errorC): void /** @@ -86,10 +80,6 @@ declare module "react-native-appsflyer" { setCollectIMEI(isCollect: boolean, successC?: SuccessCB): void setCollectAndroidID(isCollect: boolean, successC?: SuccessCB): void updateServerUninstallToken(token: string, successC?: SuccessCB): void - /** @deprecated - please use updateServerUninstallToken **/ - setGCMProjectNumber(gcmProjectNumber:any, successC?:SuccessCB, errorC?:ErrorCB): void - /** @deprecated - please use updateServerUninstallToken **/ - enableUninstallTracking(gcmProjectNumber:any, successC?:SuccessCB): void }; export default appsFlyer; diff --git a/index.js b/index.js index d2a0cac4..fcc198f5 100755 --- a/index.js +++ b/index.js @@ -29,32 +29,25 @@ function initSdk(options, success, error): Promise { } appsFlyer.initSdk = initSdk; -function trackEventCallback(eventName, eventValues, successC, errorC) { - return RNAppsFlyer.trackEvent(eventName, eventValues, successC, errorC); +function logEventCallback(eventName, eventValues, successC, errorC) { + return RNAppsFlyer.logEvent(eventName, eventValues, successC, errorC); } -function trackEventPromise(eventName, eventValues): Promise { - return RNAppsFlyer.trackEventWithPromise(eventName, eventValues); +function logEventPromise(eventName, eventValues): Promise { + return RNAppsFlyer.logEventWithPromise(eventName, eventValues); } -function trackEvent(eventName, eventValues, success, error): Promise { +function logEvent(eventName, eventValues, success, error): Promise { if (success && error) { - //trackEvent is a callback function - trackEventCallback(eventName, eventValues, success, error); + //logEvent is a callback function + logEventCallback(eventName, eventValues, success, error); } else if (!success) { - //trackEvent is a promise function - return trackEventPromise(eventName, eventValues); + //logEvent is a promise function + return logEventPromise(eventName, eventValues); } } -appsFlyer.trackEvent = trackEvent; - -/** - * iOS only - */ -appsFlyer.trackAppLaunch = () => { - return RNAppsFlyer.trackAppLaunch(); -}; +appsFlyer.logEvent = logEvent; /** * Manually record the location of the user @@ -62,10 +55,9 @@ appsFlyer.trackAppLaunch = () => { * @param longitude latitude as double. * @param latitude latitude as double. * @callback callback success callback function. - * @platform ios only */ -appsFlyer.trackLocation = (longitude, latitude, callback) => { - return RNAppsFlyer.trackLocation(longitude, latitude, callback); +appsFlyer.logLocation = (longitude, latitude, callback) => { + return RNAppsFlyer.logLocation(longitude, latitude, callback); }; /** @@ -109,13 +101,6 @@ appsFlyer.setGCMProjectNumber = (gcmProjectNumber, successC, errorC) => { return RNAppsFlyer.setGCMProjectNumber(gcmProjectNumber, successC, errorC); }; -/** - * @deprecated - */ -appsFlyer.enableUninstallTracking = (gcmProjectNumber, successC) => { - return RNAppsFlyer.enableUninstallTracking(gcmProjectNumber, successC); -}; - /** * Manually pass the Firebase / GCM Device Token for Uninstall measurement. * @@ -140,13 +125,13 @@ appsFlyer.setCustomerUserId = (userId, successC) => { /** * Once this API is invoked, our SDK no longer communicates with our servers and stops functioning. * In some extreme cases you might want to shut down all SDK activity due to legal and privacy compliance. - * This can be achieved with the stopTracking API. + * This can be achieved with the stop API. * - * @param {boolean} isStopTracking boolean should SDK be stopped. + * @param {boolean} isStopped boolean should SDK be stopped. * @callback successC success callback function. */ -appsFlyer.stopTracking = (isStopTracking, successC) => { - return RNAppsFlyer.stopTracking(isStopTracking, successC); +appsFlyer.stop = (isStopped, successC) => { + return RNAppsFlyer.stop(isStopped, successC); }; /** @@ -205,8 +190,8 @@ appsFlyer.generateInviteLink = (parameters, success, error) => { * @param appId promoted App ID. * @param campaign cross promotion campaign. */ -appsFlyer.trackCrossPromotionImpression = (appId, campaign, parameters) => { - return RNAppsFlyer.trackCrossPromotionImpression(appId, campaign, parameters); +appsFlyer.logCrossPromotionImpression = (appId, campaign, parameters) => { + return RNAppsFlyer.logCrossPromotionImpression(appId, campaign, parameters); }; /** @@ -216,8 +201,8 @@ appsFlyer.trackCrossPromotionImpression = (appId, campaign, parameters) => { * @param campaign cross promotion campaign. * @param params additional user params. */ -appsFlyer.trackAndOpenStore = (appId, campaign, params) => { - return RNAppsFlyer.trackAndOpenStore(appId, campaign, params); +appsFlyer.logAndOpenStore = (appId, campaign, params) => { + return RNAppsFlyer.logAndOpenStore(appId, campaign, params); }; /** @@ -330,11 +315,11 @@ appsFlyer.onAppOpenAttribution = callback => { * Anonymize user Data. * Use this API during the SDK Initialization to explicitly anonymize a user's installs, events and sessions. * Default is false - * @param isDeviceTrackingDisabled boolean + * @param isDeviceLoggingDisabled boolean * @param successC success callback function. */ -appsFlyer.setDeviceTrackingDisabled = (isDeviceTrackingDisabled, successC) => { - return RNAppsFlyer.setDeviceTrackingDisabled(isDeviceTrackingDisabled, successC); +appsFlyer.setDeviceLoggingDisabled = (isDeviceLoggingDisabled, successC) => { + return RNAppsFlyer.setDeviceLoggingDisabled(isDeviceLoggingDisabled, successC); }; /** @@ -380,12 +365,6 @@ appsFlyer.setSharingFilter = (partners, successC, errorC) => { appsFlyer.waitForAdvertisingIdentifierWithTimeoutInterval = (timeoutInterval, successC, errorC) => { return RNAppsFlyer.waitForAdvertisingIdentifierWithTimeoutInterval(timeoutInterval * 1000, successC, errorC); } -/** - * iOS only - */ -appsFlyer.requestTrackingAuthorization = (successC, errorC) => { - RNAppsFlyer.requestTrackingAuthorizationWith(successC, errorC); -} function AFParseJSONException(_message, _data) { this.message = _message; diff --git a/ios/RNAppsFlyer.m b/ios/RNAppsFlyer.m index cc41c73c..7dfb4aeb 100755 --- a/ios/RNAppsFlyer.m +++ b/ios/RNAppsFlyer.m @@ -6,8 +6,6 @@ #import "AppsFlyerLib.h" #endif -#import - @interface RNAppsFlyer() @end @@ -30,36 +28,6 @@ @implementation RNAppsFlyer } } -RCT_EXPORT_METHOD(requestTrackingAuthorizationWith:(RCTResponseSenderBlock)successCallback - errorCallback:(RCTResponseErrorBlock)errorCallback){ - if (@available(iOS 14, *)) { - [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { - NSString* statusDescription; - switch (status) { - case ATTrackingManagerAuthorizationStatusDenied: - statusDescription = @"Denied"; - break; - case ATTrackingManagerAuthorizationStatusAuthorized: - statusDescription = @"Authorized"; - break; - case ATTrackingManagerAuthorizationStatusRestricted: - statusDescription = @"Restricted"; - break; - case ATTrackingManagerAuthorizationStatusNotDetermined: - statusDescription = @"NotDetermined"; - break; - default: - statusDescription = @"Unknown (please report an issue to AppsFlyer github if you get this)"; - break; - } - successCallback(@[statusDescription]); - }]; - } else { - NSError* error = [NSError errorWithDomain:IOS_14_ONLY code:0 userInfo:nil]; - errorCallback(error); - } -} - RCT_EXPORT_METHOD(initSdk: (NSDictionary*)initSdkOptions successCallback :(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseErrorBlock)errorCallback) { @@ -87,11 +55,7 @@ @implementation RNAppsFlyer } } -RCT_EXPORT_METHOD(trackAppLaunch) { - [[AppsFlyerLib shared] start]; -} - -RCT_EXPORT_METHOD(trackEvent: (NSString *)eventName eventValues:(NSDictionary *)eventValues +RCT_EXPORT_METHOD(logEvent: (NSString *)eventName eventValues:(NSDictionary *)eventValues successCallback :(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseErrorBlock)errorCallback) { NSError *error = [self logEventInternal:eventName eventValues:eventValues]; @@ -104,8 +68,8 @@ @implementation RNAppsFlyer } } -RCT_EXPORT_METHOD(trackEventWithPromise: (NSString *)eventName eventValues:(NSDictionary *)eventValues - trackEventWithPromiseWithResolver:(RCTPromiseResolveBlock)resolve +RCT_EXPORT_METHOD(logEventWithPromise: (NSString *)eventName eventValues:(NSDictionary *)eventValues + logEventWithPromiseWithResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { NSError *error = [self logEventInternal:eventName eventValues:eventValues]; @@ -129,15 +93,15 @@ @implementation RNAppsFlyer callback(@[SUCCESS]); } -RCT_EXPORT_METHOD(stopTracking: (BOOL)isStopTracking callback:(RCTResponseSenderBlock)callback) { - [AppsFlyerLib shared].isStopped = isStopTracking; +RCT_EXPORT_METHOD(stop: (BOOL)isStopped callback:(RCTResponseSenderBlock)callback) { + [AppsFlyerLib shared].isStopped = isStopped; callback(@[SUCCESS]); } -RCT_EXPORT_METHOD(trackLocation: (double)longitude latitude:(double)latitude callback:(RCTResponseSenderBlock)callback) { +RCT_EXPORT_METHOD(logLocation: (double)longitude latitude:(double)latitude callback:(RCTResponseSenderBlock)callback) { [[AppsFlyerLib shared] logLocationEvent:longitude latitude:latitude]; NSArray *events = @[[NSNumber numberWithDouble:longitude], [NSNumber numberWithDouble:latitude]]; - callback(@[[NSNull null], events]); + callback(@[SUCCESS, events]); } RCT_EXPORT_METHOD(setUserEmails: (NSDictionary*)options @@ -192,6 +156,7 @@ -(NSError *) callSdkInternal:(NSDictionary*)initSdkOptions { NSString* appId = nil; BOOL isDebug = NO; BOOL isConversionData = NO; + NSNumber* interval = 0; if (![initSdkOptions isKindOfClass:[NSNull class]]) { @@ -199,6 +164,8 @@ -(NSError *) callSdkInternal:(NSDictionary*)initSdkOptions { id isConversionDataValue = nil; devKey = (NSString*)[initSdkOptions objectForKey: afDevKey]; appId = (NSString*)[initSdkOptions objectForKey: afAppId]; + interval = (NSNumber*)[initSdkOptions objectForKey: advertisingIdWaitInterval]; + isDebugValue = [initSdkOptions objectForKey: afIsDebug]; if ([isDebugValue isKindOfClass:[NSNumber class]]) { @@ -221,7 +188,6 @@ -(NSError *) callSdkInternal:(NSDictionary*)initSdkOptions { error = [NSError errorWithDomain:NO_APPID_FOUND code:1 userInfo:nil]; } - if(error != nil){ return error; } @@ -230,6 +196,11 @@ -(NSError *) callSdkInternal:(NSDictionary*)initSdkOptions { [AppsFlyerLib shared].delegate = self; } + if (interval != 0 && interval != nil){ + double timeoutInterval = [interval doubleValue]; + [[AppsFlyerLib shared] waitForAdvertisingIdentifierWithTimeoutInterval:timeoutInterval]; + } + [AppsFlyerLib shared].appleAppID = appId; [AppsFlyerLib shared].appsFlyerDevKey = devKey; [AppsFlyerLib shared].isDebug = isDebug; @@ -313,13 +284,13 @@ -(NSError *) logEventInternal: (NSString *)eventName eventValues:(NSDictionary * } //CROSS PROMOTION -RCT_EXPORT_METHOD(trackCrossPromotionImpression: (NSString *)appId campaign:(NSString *)campaign parameters:(NSDictionary *)parameters) { +RCT_EXPORT_METHOD(logCrossPromotionImpression: (NSString *)appId campaign:(NSString *)campaign parameters:(NSDictionary *)parameters) { if (appId != nil && ![appId isEqualToString:@""]) { [AppsFlyerCrossPromotionHelper logCrossPromoteImpression:appId campaign:campaign parameters:parameters]; } } -RCT_EXPORT_METHOD(trackAndOpenStore: (NSString *)appID +RCT_EXPORT_METHOD(logAndOpenStore: (NSString *)appID campaign:(NSString *)campaign customParams:(NSDictionary *)customParams) { @@ -336,7 +307,6 @@ -(NSError *) logEventInternal: (NSString *)eventName eventValues:(NSDictionary * } completionHandler: ^(NSURL * _Nullable url) { NSString *appLink = url.absoluteString; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:appLink] options:@{} completionHandler:^(BOOL success) { - }]; }]; } @@ -437,7 +407,7 @@ -(void) reportOnSuccess:(NSString *)data type:(NSString*) type { } } -RCT_EXPORT_METHOD(setDeviceTrackingDisabled: (BOOL *)b callback:(RCTResponseSenderBlock)callback) { +RCT_EXPORT_METHOD(setDeviceLoggingDisabled: (BOOL *)b callback:(RCTResponseSenderBlock)callback) { [[AppsFlyerLib shared] setDeviceLoggingDisabled:b]; callback(@[SUCCESS]); } From c592b25045b9e557594f02abe645a23c7ce50b44 Mon Sep 17 00:00:00 2001 From: Vitaly Sokolov Date: Mon, 10 Aug 2020 14:58:28 +0300 Subject: [PATCH 03/33] remove old example app --- examples/demo/App.js | 134 --- examples/demo/android/app/BUCK | 55 -- examples/demo/android/app/build.gradle | 201 ---- examples/demo/android/app/build_defs.bzl | 19 - examples/demo/android/app/debug.keystore | Bin 2257 -> 0 bytes examples/demo/android/app/proguard-rules.pro | 10 - .../android/app/src/debug/AndroidManifest.xml | 8 - .../android/app/src/main/AndroidManifest.xml | 26 - .../src/main/java/com/demo/MainActivity.java | 15 - .../main/java/com/demo/MainApplication.java | 74 -- .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 3056 -> 0 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 5024 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2096 -> 0 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 2858 -> 0 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4569 -> 0 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 7098 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 6464 -> 0 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 10676 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 9250 -> 0 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 15523 -> 0 bytes .../app/src/main/res/values/strings.xml | 3 - .../app/src/main/res/values/styles.xml | 9 - examples/demo/android/build.gradle | 38 - examples/demo/android/gradle.properties | 21 - .../android/gradle/wrapper/gradle-wrapper.jar | Bin 55616 -> 0 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 - examples/demo/android/gradlew | 188 ---- examples/demo/android/gradlew.bat | 100 -- examples/demo/android/settings.gradle | 3 - examples/demo/app.json | 4 - examples/demo/ios/Podfile | 53 - examples/demo/ios/Podfile.lock | 348 ------- examples/demo/ios/demo-tvOS/Info.plist | 53 - examples/demo/ios/demo-tvOSTests/Info.plist | 24 - .../demo/ios/demo.xcodeproj/project.pbxproj | 923 ------------------ .../xcshareddata/xcschemes/demo-tvOS.xcscheme | 129 --- .../xcshareddata/xcschemes/demo.xcscheme | 129 --- .../demo.xcworkspace/contents.xcworkspacedata | 10 - examples/demo/ios/demo/AppDelegate.h | 15 - examples/demo/ios/demo/AppDelegate.m | 42 - .../demo/ios/demo/Base.lproj/LaunchScreen.xib | 42 - .../AppIcon.appiconset/Contents.json | 38 - .../ios/demo/Images.xcassets/Contents.json | 6 - examples/demo/ios/demo/Info.plist | 57 -- examples/demo/ios/demo/main.m | 16 - examples/demo/ios/demoTests/Info.plist | 24 - examples/demo/ios/demoTests/demoTests.m | 72 -- examples/demo/package.json | 30 - 48 files changed, 2924 deletions(-) delete mode 100644 examples/demo/App.js delete mode 100644 examples/demo/android/app/BUCK delete mode 100644 examples/demo/android/app/build.gradle delete mode 100644 examples/demo/android/app/build_defs.bzl delete mode 100644 examples/demo/android/app/debug.keystore delete mode 100644 examples/demo/android/app/proguard-rules.pro delete mode 100644 examples/demo/android/app/src/debug/AndroidManifest.xml delete mode 100644 examples/demo/android/app/src/main/AndroidManifest.xml delete mode 100644 examples/demo/android/app/src/main/java/com/demo/MainActivity.java delete mode 100644 examples/demo/android/app/src/main/java/com/demo/MainApplication.java delete mode 100644 examples/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png delete mode 100644 examples/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png delete mode 100644 examples/demo/android/app/src/main/res/values/strings.xml delete mode 100644 examples/demo/android/app/src/main/res/values/styles.xml delete mode 100644 examples/demo/android/build.gradle delete mode 100644 examples/demo/android/gradle.properties delete mode 100644 examples/demo/android/gradle/wrapper/gradle-wrapper.jar delete mode 100644 examples/demo/android/gradle/wrapper/gradle-wrapper.properties delete mode 100755 examples/demo/android/gradlew delete mode 100644 examples/demo/android/gradlew.bat delete mode 100644 examples/demo/android/settings.gradle delete mode 100644 examples/demo/app.json delete mode 100644 examples/demo/ios/Podfile delete mode 100644 examples/demo/ios/Podfile.lock delete mode 100644 examples/demo/ios/demo-tvOS/Info.plist delete mode 100644 examples/demo/ios/demo-tvOSTests/Info.plist delete mode 100644 examples/demo/ios/demo.xcodeproj/project.pbxproj delete mode 100644 examples/demo/ios/demo.xcodeproj/xcshareddata/xcschemes/demo-tvOS.xcscheme delete mode 100644 examples/demo/ios/demo.xcodeproj/xcshareddata/xcschemes/demo.xcscheme delete mode 100644 examples/demo/ios/demo.xcworkspace/contents.xcworkspacedata delete mode 100644 examples/demo/ios/demo/AppDelegate.h delete mode 100644 examples/demo/ios/demo/AppDelegate.m delete mode 100644 examples/demo/ios/demo/Base.lproj/LaunchScreen.xib delete mode 100644 examples/demo/ios/demo/Images.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 examples/demo/ios/demo/Images.xcassets/Contents.json delete mode 100644 examples/demo/ios/demo/Info.plist delete mode 100644 examples/demo/ios/demo/main.m delete mode 100644 examples/demo/ios/demoTests/Info.plist delete mode 100644 examples/demo/ios/demoTests/demoTests.m delete mode 100644 examples/demo/package.json diff --git a/examples/demo/App.js b/examples/demo/App.js deleted file mode 100644 index 8d8b60ce..00000000 --- a/examples/demo/App.js +++ /dev/null @@ -1,134 +0,0 @@ -import React from 'react'; -import { - StyleSheet, - View, - Text, - Button, -} from 'react-native'; -import appsFlyer from 'react-native-appsflyer'; - -var onInstallConversionDataCanceller = appsFlyer.onInstallConversionData( - (res) => { - console.log(res); - if (JSON.parse(res.data.is_first_launch) == true) { - if (res.data.af_status === 'Non-organic') { - var media_source = res.data.media_source; - var campaign = res.data.campaign; - console.log('This is first launch and a Non-Organic install. Media source: ' + media_source + ' Campaign: ' + campaign); - } else if (res.data.af_status === 'Organic') { - console.log('This is first launch and a Organic Install'); - } - } else { - console.log('This is not first launch'); - } - } -); - - -var onAppOpenAttributionCanceller = appsFlyer.onAppOpenAttribution((res) => { - console.log(res); -}); - -appsFlyer.initSdk( - { - devKey: 'K2***********99', - isDebug: false, - appId: '41*****44', - }, - (result) => { - console.log(result); - }, - (error) => { - console.error(error); - } -); - - -const instructions = Platform.select({ - ios: 'Press Cmd+R to reload,\n' + - 'Cmd+D or shake for dev menu', - android: 'Double tap R on your keyboard to reload,\n' + - 'Shake or press menu button for dev menu', -}); - -class App extends React.Component { - - constructor(props){ - super(props); - - } - - componentWillUnmount() { - // Optionaly remove listeners for deep link data if you no longer need them - if (onInstallConversionDataCanceller) { - onInstallConversionDataCanceller(); - console.log('unregister onInstallConversionDataCanceller'); - onInstallConversionDataCanceller = null; - } - if (onAppOpenAttributionCanceller) { - onAppOpenAttributionCanceller(); - console.log('unregister onAppOpenAttributionCanceller'); - onAppOpenAttributionCanceller = null; - } - } - - TrackEventPressed() { - const eventName = "af_test_event"; - const eventValues = { - "af_event_param0" : "biz", - "af_event_param1" : "buz", - "af_event_param2" : "bizbuz" - }; - appsFlyer.trackEvent(eventName, eventValues, - (result) => { - console.log(result); - }, - (error) => { - console.error(error); - } - ) - } - - render() { - return ( - - - Welcome to the React Native AppsFlyer Test App! - - - To get started, edit App.js - - - {instructions} - - - Press to Track a AppsFlyer Event! -