AppsFlyerSDK / appsflyer-react-native-plugin

AppsFlyer plugin for React Native
MIT License
279 stars 199 forks source link

[iOS] Deep link handlers not called when app is fully closed #223

Open lucasroca opened 3 years ago

lucasroca commented 3 years ago

Plugin Version

6.1.20

On what Platform are you having the issue?

iOS

What did you do?

Installed the latest version of the plugin

What did you expect to happen?

onDeepLink to be called

What happened instead?

The handler wasn't triggered

Please provide any other relevant information.

On iOS, react-native-appsflyer version 6.1.10, when clicking a OneLink the app opens butonAppOpenAttribution is not triggered when the app is fully closed.

Then I upgraded to react-native-appsflyer version 6.1.20 to test unified links. Again, onDeepLink works on every case except when the app is installed but fully closed and I open a OneLink.

I tried both on simulator and real device with no luck.

goldqwert commented 3 years ago

Also problem, please fix this bag

Voidozzer commented 3 years ago

Same problem here

Plugin 6.1.20 React Native 0.63.3

Appears only on iOS, on Android works as expected.

lucasroca commented 3 years ago

Hi @amit-kremer93, do you have any updates on this?

amit-kremer93 commented 3 years ago

Did you follow this?? For now, you can use onInstallConversionData listener to handle direct deep link in iOS by checking if is_first_launch === false. it's not the best solution but it will work until we figure it out

rborn commented 3 years ago

onInstallConversionData is not enough to get all the params. I had to downgrade to 6.0.50 to restore the behaviour :(

goldqwert commented 3 years ago

onInstallConversionData is not enough to get all the params. I had to downgrade to 6.0.50 to restore the behaviour :(

6.0.50 - does not handled when the app is turned on :( latest version - handled when app on, but not handled when start :(

can developers combine these 2 functions?

or maybe add in onInstallConversionData all params?

amit-kremer93 commented 3 years ago

@Goldyukol in which type of deep link do you use? URL scheme or universal link? 6.0.50 works fine for me when the app in the background and when fully closed

rborn commented 3 years ago

@amit-kremer93 how does it work for you ? we use appsflyer links

goldqwert commented 3 years ago

@Goldyukol in which type of deep link do you use? URL scheme or universal link? 6.0.50 works fine for me when the app in the background and when fully closed

In latest version this features doesn't work

lucasroca commented 3 years ago

Did you follow this?? For now, you can use onInstallConversionData listener to handle direct deep link in iOS by checking if is_first_launch === false. it's not the best solution but it will work until we figure it out

Yes, I've followed those steps. The issue still remains. As mentioned by @rborn, using onInstallConversionData doesn't help much.

@Goldyukol in which type of deep link do you use? URL scheme or universal link? 6.0.50 works fine for me when the app in the background and when fully closed

I'm using universal links.

csantarin commented 3 years ago

@amit-kremer93 like the rest of us here, definitely still happening on my end.

On relaunching the app, onAppOpenAttribution doesn't happen, but if it was running in the background, direct deep links would successfully trigger it.

amit-kremer93 commented 3 years ago

It seems like the issue started after the native SDK was upgraded and we are working on a solution. Sorry for the inconvenience.

amit-kremer93 commented 3 years ago

I released a new version (6.1.40) with a fix for the onAppOpenAttribution in iOS. The implementation has slightly changed so please see this but the flow is the same. Please let us know here if there is any problem. thanks!

csantarin commented 3 years ago

Update

Those who are running into this might find https://github.com/AppsFlyerSDK/appsflyer-react-native-plugin/issues/223#issuecomment-768371228 useful.

Reasoning here and here.


Please let us know here if there is any problem.

@amit-kremer93 Yup, unfortunately, there is one.

I opened the app from the phone's email client. Then shortly after, the app crashed before it could even start logging anything to the JavaScript console. Here's the native log. ML.Debug refers to my local app process.

default 12:17:28.772654+0800    ML.Debug    [DEBUG] AppsFlyer: [HTTP] 
Result: {
    data = {length = 4, bytes = 0x226f6b22};
    dataStr = "\"ok\"";
    retries = 2;
    statusCode = 200;
    taskIdentifier = 3;
}                
Error: (null)
default 12:17:28.772732+0800    ML.Debug    [DEBUG] AppsFlyer: Loading conversion data
default 12:17:28.773572+0800    ML.Debug    [DEBUG] AppsFlyer: [GCD-A02] -[RNAppsFlyer onConversionDataSuccess:]:
{
    "af_message" = "organic install";
    "af_status" = Organic;
    "install_time" = "2021-01-18 04:06:20.689";
    "is_first_launch" = 0;
}
default 12:17:28.775784+0800    ML.Debug    [DEBUG] AppsFlyer: [CACHE] Deleting file: /var/mobile/Containers/Data/Application/1E631D5D-803D-4A15-8B56-FA65694DFF2D/Library/Caches/appsflyer-v1/632636244.2472.plist
default 12:17:28.775850+0800    ML.Debug    [DEBUG] AppsFlyer: [HTTP] Dealloc. Time elapsed for: `160-1610943444.211549` - 3.944231986999512
default 12:18:09.942508+0800    ML.Debug    *** Assertion failure in -[RCTEventEmitter sendEventWithName:body:](), /Users/csantarin/moneylion/mobile-app/node_modules/react-native/React/Modules/RCTEventEmitter.m:50
default 12:18:10.253181+0800    ML.Debug    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error when sending event: onAttributionFailure with body: {"status":"failure","type":"onAttributionFailure","data":"Authentication Failed"}. Bridge is not set. This is probably because you've explicitly synthesized the bridge in RNAppsFlyer, even though it's inherited from RCTEventEmitter.'
*** First throw call stack:
(0x1853619d8 0x1996cab54 0x18527050c 0x1865b9238 0x1051ecf80 0x1058948a8 0x1058946c8 0x186657614 0x1852e1bf0 0x1852e1af0 0x1852e0e38 0x1852db3e0 0x1852daba0 0x19c018598 0x187bca3d8 0x187bcf958 0x104604564 0x184fb9568)
amit-kremer93 commented 3 years ago

@csantarin {"status":"failure","type":"onAttributionFailure","data":"Authentication Failed"} means that you have an issue with your devKey. about the crash, i released an hot fix.

haipham-kontist commented 3 years ago

@amit-kremer93 , I'm testing version 6.1.41

I already updated didFinishLaunchingWithOptions.

goldqwert commented 3 years ago

@ amit-kremer93 , тестирую версию6.1.41

  • На Android: он работает в любом сценарии, когда приложение находится в фоновом режиме или когда оно полностью закрыто.
  • На ios: не работает, если приложение полностью закрыто. Работает, если приложение находится в фоновом режиме.

Я уже обновился didFinishLaunchingWithOptions.

How you updated didFinishLaunchingWithOptions?

Send code pls

haipham-kontist commented 3 years ago

How you updated didFinishLaunchingWithOptions?

Send code pls

You can find it in the updated guide: https://github.com/AppsFlyerSDK/appsflyer-react-native-plugin/blob/master/Docs/Guides.md#import

  if(_AppsFlyerdelegate == nil){
    _AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
  }
  [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
goldqwert commented 3 years ago

@amit-kremer93 , I'm testing version 6.1.41

  • On android: it works in either scenarios, when app is in background, or when it's fully closed.
  • On ios: it doesn't work if app is fully closed. It works if app is in background.

I already updated didFinishLaunchingWithOptions.

  [[FBSDKApplicationDelegate sharedInstance] application:application
    didFinishLaunchingWithOptions:launchOptions];

added after?

  if(_AppsFlyerdelegate == nil){
    _AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
  }
  [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
goldqwert commented 3 years ago

I released a new version (6.1.40) with a fix for the onAppOpenAttribution in iOS. The implementation has slightly changed so please see this but the flow is the same. Please let us know here if there is any problem. thanks!

Problem is not resolved

csantarin commented 3 years ago

Update

Those who are running into this might find https://github.com/AppsFlyerSDK/appsflyer-react-native-plugin/issues/223#issuecomment-768371228 useful.

Reasoning here and here.


@Goldyukol not-maintainer here. On 6.1.41, I imagine it should look like this on a brand new AppDelegate.m:

#import <RNAppsFlyer.h>
#import <React/RCTLinkingManager.h>
#import <AppsFlyerLib/AppsFlyerLib.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Flipper init here...

  if(_AppsFlyerdelegate == nil){
    _AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
  }
  [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];

  // React Native Bridge and Root View init here...
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] 
    initWithBridge:bridge
    moduleName:@"FiftyViewsUnderTheAppiumSea"
    initialProperties:nil
  ];

  // More on React Native Bridge and Root View init here...

  return YES;
}

Correct me if I'm wrong, @amit-kremer93. That's how I'm initializing the SDK on my end.

csantarin commented 3 years ago

{"status":"failure","type":"onAttributionFailure","data":"Authentication Failed"} means that you have an issue with your devKey. about the crash, i released an hot fix.

Right you are, @amit-kremer93. But I've followed the iOS SDK / RN plugin integration guide. The devKey and appId are correct. So, I don't get it. Why would I have this issue?

On my end, .initSdk(config) is called right after subscribers, i.e. onInstallConversionData, onAppOpenAttribution, etc.

jwebcat commented 3 years ago

@amit-kremer93 we are also experiencing a similar issue. On the latest version of the plugin (6.1.41) for iOS: if the app is fully closed, after tapping a onelink in the phones email client, the phone crashes with the following error

[DEBUG] AppsFlyer:                        
[Shortlink] OneLink:(null)                       
[Shortlink] Response Info:{
    data = {length = 21, bytes = 0x41757468656e7469636174696f6e204661696c6564};
    dataStr = "Authentication Failed";
    retries = 0;
    statusCode = 401;
    taskIdentifier = 1;
}                       
[Shortlink] Error: Error Domain=com.appsflyer.sdk.serialize Code=61 "Authentication Failed" UserInfo={NSLocalizedDescription=Authentication Failed}

Everything is setup according to the docs and was not crashing before updating the plugin (although onDeepLink was not firing on iOS). I have made the recommended changes from the new readme to the AppDelegate.m as well.

If the app is in the background, it works as expected i.e. the onDeepLink handler is called and no crash.

colaquecez commented 3 years ago

Same here, if i open the app and then i use deep link it works, but when the app is completely closed does not work :(

csantarin commented 3 years ago

@colaquecez @jwebcat @Goldyukol @haipham-kontist @lucasroca @Voidozzer @rborn

I found something with the help of their support team that might help you out.

  if(_AppsFlyerdelegate == nil){
    _AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
  }
  [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
+  [AppsFlyerLib shared].appsFlyerDevKey = @"YOUR_APPSFLYER_DEV_KEY";

For the app I work with, this is sorely needed, on top of the initSdk() params. This isn't mentioned in the docs, though.

@amit-kremer93 I feel like this is a hack, but it holds for the time being. Would it be possible to remedy this gotcha or at least make it known to everyone in the Init SDK guide?


@amit-kremer93 The crash that I mentioned in https://github.com/AppsFlyerSDK/appsflyer-react-native-plugin/issues/223#issuecomment-761987345 is no longer there. There was a remnant code lying about (from AppsFlyerFramework 4.10.x days) in AppDelegate.m > application:applicationDidBecomeActive that had to be removed from our codebase as it was causing all of those crashes:

(void)applicationDidBecomeActive:(UIApplication *)application {
  // Don't need the below.
-  [[AppsFlyerLib shared] start];
amit-kremer93 commented 3 years ago

@csantarin I feel like this is a hack, but it holds for the time being. Would it be possible to remedy this gotcha or at least make it known to everyone in the Init SDK guide? yes, you are right this is a workaround for now. it happened because of some improvements in the iOS SDK that launches faster than the plugin in react-native so we working on a long-term fix.

rborn commented 3 years ago

@csantarin thanks a lot for this. could you please explain where to put the code above? Because I don't have anything similar to this in my appdelegate 🤗

  if(_AppsFlyerdelegate == nil){
    _AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
  }
  [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
+  [AppsFlyerLib shared].appsFlyerDevKey = @"YOUR_APPSFLYER_DEV_KEY";
csantarin commented 3 years ago

@rborn assuming latest React Native, in application:didFinishLaunchingWithOptions:

AppDelegate.m

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>

// AppsFlyer imports
#import <RNAppsFlyer.h>
#import <AppsFlyerLib/AppsFlyerLib.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Flipper init here...

  // AppsFlyer init here...
  if(_AppsFlyerdelegate == nil){
    _AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
  }
  [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
  [AppsFlyerLib shared].appsFlyerDevKey = @"YOUR_APPSFLYER_DEV_KEY"; // HACK: iOS SDK is faster than RN plugin

  // React Native Bridge and Root View init here...
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] 
    initWithBridge:bridge
    moduleName:@"FiftyViewsUnderTheAppiumSea"
    initialProperties:nil
  ];

  // More on React Native Bridge and Root View init here...

  return YES;
}

Like in https://github.com/AppsFlyerSDK/appsflyer-react-native-plugin/issues/223#issuecomment-762352475, except you now have:

[AppsFlyerLib shared].appsFlyerDevKey = @"YOUR_APPSFLYER_DEV_KEY";

It's also in the docs. Check it out.

jwebcat commented 3 years ago

@amit-kremer93 @rborn I have implemented the hacky workaround for plugin version 6.1.41 and now the onDeepLink handler is called and the app no longer crashes. There seems to be a new issue introduced however, the onDeepLink handler is not called intermittently both with the app fully closed and in the background. It works about 80% of the time. This makes me think perhaps a race condition is introduced with this latest workaround. This was tested on physical devices (iOS 13.1.2 and 14.4) Is this happening for anyone else?

In the code below af_dp replaced with xxx

When the Onelink works and calls the onDeepLink handler the native logs show:
[DEBUG] AppsFlyer:                        
[Shortlink] OneLink:{
    "af_dp" = "xxx";
    "deep_link_value" = myProgram;
    "media_source" = Email;
    pid = Email;
}                       
[Shortlink] Response Info:{
    data = {length = 90, bytes = 0x7b227069 64223a22 456d6169 6c222c22 ... 22456d61 696c227d };
    dataStr = "{\"pid\":\"Email\",\"deep_link_value\":\"myProgram\",\"af_dp\":\"xxx\",\"media_source\":\"Email\"}";
    retries = 0;
    statusCode = 200;
    taskIdentifier = 5;
}                       
[Shortlink] Error: (null)

followed by

[DEBUG] AppsFlyer: [GCD-A02] -[RNAppsFlyer onConversionDataSuccess:]:
{
    "af_message" = "organic install";
    "af_status" = Organic;
    "install_time" = "2021-01-27 21:51:15.073";
    "is_first_launch" = 0;
}
When the Onelink doesn't work and fails to call onDeepLink handler, the native logs only show:
[DEBUG] AppsFlyer:                        
[Shortlink] OneLink:{
    "af_dp" = "xxx";
    "deep_link_value" = myProgram;
    "media_source" = Email;
    pid = Email;
}                       
[Shortlink] Response Info:{
    data = {length = 90, bytes = 0x7b227069 64223a22 456d6169 6c222c22 ... 22456d61 696c227d };
    dataStr = "{\"pid\":\"Email\",\"deep_link_value\":\"myProgram\",\"af_dp\":\"xxx\",\"media_source\":\"Email\"}";
    retries = 0;
    statusCode = 200;
    taskIdentifier = 5;
}                       
[Shortlink] Error: (null)

In this case [RNAppsFlyer onConversionDataSuccess:]: is never called and it fails to call either the onInstallConversionData or onDeepLink handlers.

With the plugin version 6.1.20 it calls the onDeepLink handler successfully every time you tap a Onelink when the app is in the foreground, but is not called when the app is fully closed.

curiousdustin commented 3 years ago

I am also having this issue in version 6.1.41. onDeepLink is only called if the app is already open. I have tried everything above including the "hack" from @csantarin, and it still does not work.

I have tried on simulator and real device.

What else can I try?

curiousdustin commented 3 years ago

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{  
  [Bugsnag start];

  // Firebase
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }

  // AppsFlyer
  if(_AppsFlyerdelegate == nil){
    _AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
  }
  [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
  [AppsFlyerLib shared].appsFlyerDevKey = [ReactNativeConfig envFor:@"APPSFLYER_DEV_KEY_IOS"];

  // Enable Logging For Release Builds
  // RCTSetLogThreshold(RCTLogLevelInfo - 1);

#ifdef FB_SONARKIT_ENABLED
  InitializeFlipper(application);
#endif

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"pinna" initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  return YES;
}

My setup() function run as soon as possible:

static setup(handleAppsFlyerData) {
    let appsFlyerOptions = {
      devKey: APPSFLYER_DEV_KEY_IOS,
      appId: APPSFLYER_APP_ID_IOS,
      onInstallConversionDataListener: true,
      onDeepLinkListener: true,
      isDebug: true
    };

    if (handleAppsFlyerData) {
      onDeepLinkCanceller = appsFlyer.onDeepLink(res => {
        console.log('appsFlyer.onDeepLink', res);
        handleAppsFlyerData(res.data);
      });

      onInstallConversionDataCanceller = appsFlyer.onInstallConversionData(
        res => {
          console.log('appsFlyer.onInstallConversionData', res);
          if (
            res &&
            res.data &&
            res.data.is_first_launch &&
            JSON.parse(res.data.is_first_launch) == true
          ) {
            handleAppsFlyerData(res.data);
          }
        }
      );
    }

    if (Device.isIos) {
      // Do not need to call this when using the AppsFlyer SDK with IDFA removed
      // appsFlyer.disableAdvertisingIdentifier(true);
      appsFlyer.disableCollectASA(true);
    }

    appsFlyer.initSdk(
      appsFlyerOptions,
      result => {
        debug.log('appsFlyer.initSdk', result);
      },
      error => {
        debug.log('appsFlyer.initSdk ERROR', error);
      }
    );
  }
amit-kremer93 commented 3 years ago

@jwebcat @curiousdustin if you want to use unified deep link instead of onAppOpenAttribution, try to replace [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate]; with [[AppsFlyerLib shared] setDeepLinkDelegate:_AppsFlyerdelegate]

curiousdustin commented 3 years ago

@amit-kremer93 , that seems to have worked for me. Thanks!

You say replace. Is there any reason we should also keep the setDelegate line as well?

jwebcat commented 3 years ago

@amit-kremer93 after implementing the following, there is no change:

@jwebcat @curiousdustin if you want to use unified deep link instead of onAppOpenAttribution, try to replace [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate]; with [[AppsFlyerLib shared] setDeepLinkDelegate:_AppsFlyerdelegate]

The same issue that I described persists (onDeepLink only fires ~80% of the time both with the app in the background and fully closed.)

amit-kremer93 commented 3 years ago

@curiousdustin it can cause conflicts with these two listeners. if you want to use onAppOpenAttribution you must use setDelegate and if you want to use onDeepLink you must use setDeepLinkDelegate. @jwebcat it happens randomly? or in certain flows? all this issue began because of performance and timing problems in React-Native and iOS, so try to call if(_AppsFlyerdelegate == nil){ _AppsFlyerdelegate = [[RNAppsFlyer alloc] init]; } [[AppsFlyerLib shared] setDeepLinkDelegate_AppsFlyerdelegate]; [AppsFlyerLib shared].appsFlyerDevKey = @"YOUR_APPSFLYER_DEV_KEY"; at the top of your didFinishLaunchingWithOptions

jwebcat commented 3 years ago

@amit-kremer93 I already tried moving it to the top of didFinishLaunchingWithOptions and it doesn't make a difference.

With the previous version 6.1.20 the onDeepLink fires 100% of the time with the app in the background. It fails to call onDeepLink at all with the app fully closed.

With this version 6.1.41 onDeepLink only fires about 70% of the time. The rest of the time it just opens the app. It seems to consistently fail to call onDeepLink on the first press of a onelink. Sometimes it works several times, then fails to call onDeepLink on the 3rd or 4th press of a onelink. It seems to fail as described for all scenarios / flows (app in the background and fully closed). This behavior for me points to a race condition of some sort, especially because in the previous version of the plugin it works as expected with the app in the background.

This issue is blocking our team from utilizing this feature. Any update on an actual fix would be much appreciated.

rborn commented 3 years ago

@amit-kremer93 any update on this? 🙏

jwebcat commented 3 years ago

@rborn this is fixed for us in plugin v6.2.10. I haven't tried the latest version that was just released.

amit-kremer93 commented 3 years ago

@rborn as @jwebcat wrote, this issue was fixed in v6.2.10 and also in the next releases

rborn commented 3 years ago

@amit-kremer93 @jwebcat thank you, will test today/tomorrow and let you know :)

rborn commented 3 years ago

@amit-kremer93 @jwebcat Ok, tested with "react-native-appsflyer": "6.2.31", but the app still doesn't receive the deeplinks on cold start :( (ios)

amit-kremer93 commented 3 years ago

@rborn please be sure you follow the new docs

tomoakley commented 3 years ago

I'm trying to implement Unified Deep Linking, but can't get onDeepLinking to fire when I run xcrun simctl openurl booted https://mydomain.onelink.me/path/tolink (which has a deep_link_value set in the creation UI). Launching the app via the URL scheme, i.e xcrun simctl openurl booted myappscheme://test-deep-link fires onAppOpenAttribution with the correct data in, and onInstallConversionData fires correctly too. I've been over the setup in the JS and Obj-C in AppDelegate.m multiple times and it all seems to be correct. I'm using the latest version of react-native-appsflyer (6.2.41) so I don't have any setDelegate or setDeepLinkDelegate. Here is the code I am using:

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {
  [[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
  return YES;
}

// 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 {
  [[AppsFlyerAttribution shared] handleOpenUrl:url sourceApplication:sourceApplication annotation:annotation];
  return YES;
}

// Reports app open from URL Scheme deep link for iOS 10
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *) options {
  [[AppsFlyerAttribution shared] handleOpenUrl:url options:options];
  return YES;
}
  const onInstallConversionDataCanceller = (callback) =>
    appsFlyer.onInstallConversionData(callback)

  const onAppOpenAttributionCanceller = (callback) =>
    appsFlyer.onAppOpenAttribution(callback)

  const onDeepLinkCanceller = (callback) => appsFlyer.onDeepLink(callback)

  appsFlyer.initSdk(
    {
      devKey: Config.APPSFLYER_DEV_KEY,
      appId: <team id>,
      isDebug: true,
      onInstallConversionDataListener: true,
      openDeepLinkListener: true,
    },
    (result) => {
      console.log(`AppsFlyer initalised successfully: ${result}`)
    },
    (error) => {
      console.log(`There was a problem initalising AppsFlyer: ${error}`)
    }
  )

(the callback methods are passed in from another method. These shouldn't be a problem, for now they are just the standard ones in the docs). The init success callback fires successfully. Also this is only for iOS, I have yet to try Android.

amit-kremer93 commented 3 years ago

@tomoakley please contact our support team: support@appsflyer.com

jwebcat commented 3 years ago

@tomoakley looks like in your appsFlyer.initSdk options, you need change openDeepLinkListener: true to be onDeepLinkListener: true then it should work as expected.

rborn commented 3 years ago

@amit-kremer93 I did 😅 and it seems that all works now, I forgot some delegate from the older versions in AppDelegate.m Thanks for the help 😻

tomoakley commented 3 years ago

@tomoakley looks like in your appsFlyer.initSdk options, you need change openDeepLinkListener: true to be onDeepLinkListener: true then it should work as expected.

thanks @jwebcat! I've changed it, but onDeepLink callback still isn't being called. I will contact the support team (unless anyone else spots anything).

tomoakley commented 3 years ago

update - I can now get onDeepLink and onInstallConversionData called for launches via the URL scheme e.g myapp:// but only onInstallConversionData for launching via a OneLink, onDeepLink callback does not get called.

lucasroca commented 3 years ago

I've updated to 6.2.41 and follow the docs. My initial problem is solved now. Thanks for the help!

eomttt commented 3 years ago

@amit-kremer93 hello, "react-native-appsflyer": "^6.3.20", always fire onAppOpenAttribution method not called when ios app is fully closed

  func application(
    _ app: UIApplication,
    open url: URL,
    options: [UIApplication.OpenURLOptionsKey: Any] = [:]
  ) -> Bool {
    AppsFlyerAttribution.shared().handleOpenUrl(url, options: options)
    return RCTLinkingManager.application(app, open: url, options: options)
  }

  func application(
    _ application: UIApplication,
    continue userActivity: NSUserActivity,
    restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
  ) -> Bool {
    AppsFlyerAttribution.shared().continueUserActivity(userActivity, restorationHandler: nil)
    return RCTLinkingManager.application(application, continue: userActivity) { _ in }
  }

  func application(
    _ application: UIApplication,
    open url: URL,
    sourceApplication: String?,
    annotation: Any) -> Bool {
    AppsFlyerAttribution.shared().handleOpenUrl(url, sourceApplication: sourceApplication, annotation: annotation)
    return true
  }