AppsFlyerSDK / appsflyer-react-native-plugin

AppsFlyer plugin for React Native
MIT License
285 stars 202 forks source link

[iOS 14.5] onDeepLink no triggered #295

Open lucasroca opened 3 years ago

lucasroca commented 3 years ago

Report

onDeepLink handler not being called in iOS 14.5

Plugin Version

"react-native": "0.64.1" "react-native-appsflyer": "6.2.41"

On what Platform are you having the issue?

iOS

What did you do?

I updated to Xcode 12.5 and tested opening a deep link on iOS 14.5, and it didn't trigger onDeepLink. The handler is working fine on iOS 14.4 and 13.5. I tried adding timeToWaitForATTUserAuthorization: 10, but it didn't help.

export const initAppsFlyer = () => {
  const onDeepLinkCanceller = appsFlyer.onDeepLink(() => {
    try {
      console.log('Deep link handler'); // <---- Never executed
    } catch (e) {
      console.log('');
    }
  });

  appsFlyer.initSdk(
    {
      devKey: APPSFLYER_KEY,
      isDebug: false,
      appId: IOS_APP_ID,
      onDeepLinkListener: true
    },
    () => console.log('Success'), // Success handler
    () => console.log('Failed') // Error handler
  );

  return onDeepLinkCanceller;
};

What did you expect to happen?

Deep link handler to be logged

What happened instead?

Nothing happens

Please provide any other relevant information.

I have Firebase and Facebook SDK installed, so I'm using react-native-permissions to check and request permissions to ATT.


I'd appreciate some help here. I might be missing some configuration. Thanks in advance!

trinhenouvo commented 3 years ago

Our team is facing the same issue with the deferred link on iOS 14.5. The onDeepLink is never triggered in the first launch.

Plugin Version:

"react-native-appsflyer": "6.2.42"

Environment:

amit-kremer93 commented 3 years ago

@lucasroca @trinhnguyen-enouvo the handler doesn't work at all? or just when the app is in the background/cold start?

poonai commented 3 years ago

@amit-kremer93 we facing the same issue in android as well.

when the app is in background, onDeepLink works if the the app is closed and the app is opened via deep link then onDeepLink doesn't get triggered

kbihani commented 3 years ago

We are facing the same issue in iOS 14.5 with appsflyer version 6.2.41. The deep link handler is not triggered at all (app in background or closed state) Have followed the steps mentioned here: https://github.com/AppsFlyerSDK/appsflyer-react-native-plugin/blob/master/Docs/Guides.md#deeplinking

amit-kremer93 commented 3 years ago

@poonai @lucasroca @kbihani try to update to the plugin's latest version. it works with ios 14.5

ACHP commented 3 years ago

@amit-kremer93 Are you sure it does works ? Using the provided sample app, it does not ...

Using

   "react-native": "0.63.4",
   "react-native-appsflyer": "6.3.20",

Tested on simulator (iPhone 11 and iphone 12 max)

kbihani commented 3 years ago

@ACHP It worked for us after upgrading to 6.3.50. We did face an issue where deep links were not working when iOS app was opened from a closed state.

We made a change to the file node_modules/react-native-appsflyer/ios/AppsFlyerAttribution.m b/node_modules/react-native-appsflyer/ios/AppsFlyerAttribution.m:

We needed to add this line twice: [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:self.restorationHandler]; [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:self.restorationHandler];

And it started working.

michalis-ligopsychakis commented 3 years ago

I have the same problem.. I use react-native-appsflyer@6.4.0 and simulator iOS 14.4 ... The "onInstallConversionData" called on every launch correctly but the "onDeepLink" not .. On Android works fine.. @kbihani I tried your solution but didn't worked..

Is there any other solution :) Any help is welcome!

michalis-ligopsychakis commented 3 years ago

Finally found that "onDeepLink" not get called because I am working with scenes on iOS..

But still, any ideas about how to implement the deep linking methods on AppDelegate.m in order for this to work ..?

amit-kremer93 commented 2 years ago

@michalis-ligopsychakis if you are using universal-links use this if you are using uri-scheme, use this:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *) options {
    [[AppsFlyerAttribution shared] handleOpenUrl:url options:options];
    return YES;
}
GoldenWings commented 2 years ago

@amit-kremer93

@michalis-ligopsychakis if you are using universal-links use this if you are using uri-scheme, use this:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *) options {
    [[AppsFlyerAttribution shared] handleOpenUrl:url options:options];
    return YES;
}

I am using universal links, and i have the setup you mentioned in AppDelegate.m, The universal link always fall back and neither onDeepLink nor onOpenAppAttribution gets fired, i am testing on simulator btw the fallback happens i suppose because the following snippet [RCTLinkingManager application:application openURL:url options:options];

amit-kremer93 commented 2 years ago

@GoldenWings try to go to node_modules/react-native-appsflyer/ios/AppsFlyerAttribution.m and duplicate this line. it should look like this:

else if(self.userActivity && self.restorationHandler){
        [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:self.restorationHandler];
        [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:self.restorationHandler];
        self.userActivity = nil;
        self.restorationHandler = nil;
    }

if it works for you, a fix should be released in the next release

GoldenWings commented 2 years ago

@GoldenWings try to go to node_modules/react-native-appsflyer/ios/AppsFlyerAttribution.m and duplicate this line. it should look like this:

else if(self.userActivity && self.restorationHandler){
        [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:self.restorationHandler];
        [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:self.restorationHandler];
        self.userActivity = nil;
        self.restorationHandler = nil;
    }

if it works for you, a fix should be released in the next release

Actually onDeepLink working without the need of adding those lines will double check tomorrow. But onAppOpenAttribution it seems not to get fired at all if i used it in place of onDeepLink, just to make sure i am getting it right, onDeepLink is for universal links and onAppOpenAttribution is for URI scheme is that the only difference?

amit-kremer93 commented 2 years ago

@GoldenWings onDeepLink and onAppOpenAttribution are both for universal links and uri scheme. the difference is the onDeepLink is newer then onAppOpenAttribution. you can read more here

artyorsh commented 2 years ago

@GoldenWings try to go to node_modules/react-native-appsflyer/ios/AppsFlyerAttribution.m and duplicate this line. it should look like this:

else if(self.userActivity && self.restorationHandler){
        [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:self.restorationHandler];
        [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:self.restorationHandler];
        self.userActivity = nil;
        self.restorationHandler = nil;
    }

if it works for you, a fix should be released in the next release

Actually onDeepLink working without the need of adding those lines will double check tomorrow. But onAppOpenAttribution it seems not to get fired at all if i used it in place of onDeepLink, just to make sure i am getting it right, onDeepLink is for universal links and onAppOpenAttribution is for URI scheme is that the only difference?

Although I don't see any technical explanation of why this should work, I've tried this patch but no luck. iOS 15.2.1, physical device, release build.

artyorsh commented 2 years ago

What's worth mentioning, I was able to make this work by implementing the DeeplinkDelegate to the AppDelegate of our app. In this case RNAppfslyers' (the one is set with initSdk) delegate is ignored before the bridge is initialized, but at least it gives a possibility to handle deep links on cold start by sending handled events back to JS with EventEmitter (this is how it works also in the library), not relying on boxed onDeepLink.

@amit-kremer93 I think the initial problem is that the .deeplinkDelegate is only set when the RNAppsflyers' initSdk is called, and the native deep linking functions sometimes are called much earlier causing apps to lose initial events. Do you think a firebase-like approach could help in solving this problem?

amit-kremer93 commented 2 years ago

@artyorsh did you implement deeplinks handling like the docs? if yes, it covers the problem you mentioned where the bridge is initialized later and lose initial events

artyorsh commented 2 years ago

@amit-kremer93 Unfortunately, it doesn't. The AppsFlyerAttribution checks if the bridge is initialized and stores the UserActivity for later use if it doesn't, but the event is still not fired on a cold start.

GoldenWings commented 2 years ago

@GoldenWings onDeepLink and onAppOpenAttribution are both for universal links and uri scheme. the difference is the onDeepLink is newer then onAppOpenAttribution. you can read more here

Thankfully everything is working just fine now, except for deferred deep linking the onLinking gets fired twice once with isDeferred false and once with isDeferred true

msvargas commented 2 years ago

Hi @GoldenWings One question please, does the deferred deep link work for you? I always get isDeferred equals to false and the deepLinkStatus equal to NOT_FOUND, I really appreciate any help, thanks

natestgermain commented 2 years ago

Hi everyone! Anyone seeing that onDeepLink isn't being called for Android devices when the app is closed and then opened?

We're seeing that onDeepLink doesn't get called on first open after the app being closed. When we try to click the deep link again for the second time (in the same way as the first) while the app is now open, onDeepLink is called and behaves as expected. Thanks!

yabasha commented 1 year ago

I am facing the same issue with deep link on iOS 16.3. The onDeepLink is never triggered

Plugin Version:

"react-native": "0.63.5",
"react-native-appsflyer": "^6.9.1"

Environment:

iOS: 16.3

annasychugina commented 1 year ago

@yabasha Any ideas how to fix it? I contacted with support but there is no solution yet.

I have the same issue but when the app was fully closed. In the foreground it works.

yabasha commented 1 year ago

@annasychugina for me it is never triggered for iOS 16 either foreground or background but on Android 12 it works, I don't know what to do as I already started the project using appsflyer!!!

miladdev85 commented 1 year ago

@annasychugina Did you get any response from the support or managed to solve this? Facing the same issue right now..

OrenMag commented 1 year ago

We are having the same issue. @amit-kremer93 we run "react-native-appsflyer": "6.10.2"

Deeplinking + deferred deeplinking works well with onelink.me links But when using an email service (like iterable) - the deeplinking when the app is installed already is resulted with "data": "Authentication Failed", While deferred deeplinking works

Any idea?

thaibuiminhncc commented 10 months ago

Has it been resolved yet?

eramudeep commented 8 months ago

i am also facing same issue, Did anyone able to solve the issue ?

VadymBezsmertnyi commented 8 months ago

i am also facing same issue

gustafholmer commented 6 months ago

Same!

Falco26 commented 6 months ago

Any news on this issue?

yvza commented 5 months ago

my issue is only on android when app killed, onDeepLink return nothing

other case is working well