Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep link is received twice in iOS in Ionic 2 #304

Closed
bea91 opened this issue Mar 22, 2017 · 14 comments
Closed

Deep link is received twice in iOS in Ionic 2 #304

bea91 opened this issue Mar 22, 2017 · 14 comments

Comments

@bea91
Copy link

bea91 commented Mar 22, 2017

Hi,
We are using Branch with the latest version of Ionic 2 (2.2.0). We have found that deep link is received twice in iOS on cold start.

How to reproduce the issue:

  1. Install latest Ionic CLI 2.2.1.
  2. Install Cordova 6.5.0.
  3. Create a brand new project with: ionic start --v2 myApp tabs.
  4. Install branch plugin.
  5. Follow plugin configuration and setup.
  6. Build and run in an iPhone 6 with iOS 10.2.
  7. Kill the app.
  8. Generate a branch link and click on it.
  9. The app starts and the link is received twice.

The expected behavior is to receive only one time the deep link.

We can provide a sample project already created and a link, too.

Regards and thanks in advance,
Bea

@ethanneff
Copy link
Contributor

Hello bea91,

Thank you for bring this to our attention and giving us the steps to reproduce it. We will look into this tomorrow and report back any information/solutions we can find.

Thanks,

@ethanneff
Copy link
Contributor

Hello again,

I apologize for the delay. The good news is the duplicate data return on app terminate has been fixed. Please do the following to remove the Branch SDK and update it to the latest version (2.5.14).

cordova plugin rm branch-cordova-sdk
cordova build ios

Thank you for your patience and thank you for the steps to reproduce this issue.

Best,

@bea91
Copy link
Author

bea91 commented Apr 6, 2017

Thank you so much!. After upgrading Branch plugin to the latest version, all is working fine as expected again.

Regards,
Bea

@bea91
Copy link
Author

bea91 commented May 16, 2017

Hi,
@ethanneff I am sorry, but the issue is still happening when the app is in background. We were closing the app when we tested the solution, but if the app is in background and the branch init session is called after the resume event, deep links are received twice.
We have tested this in 2.5.14 and 2.5.17.
Regards,
Bea

@ethanneff ethanneff reopened this May 17, 2017
@ethanneff
Copy link
Contributor

Hello,

I am reopening this issue and will investigate further. I have a feeling one of our underlying SDKs (Android and iOS) could be queuing the network requests whenever you try opening the app without an internet connection. Once you finally open the app with an internet connection, you get the queue of all the previous request data. This is my assumption which I will investigate.

In the meantime, can you confirm your testing process is the same? Additionally, can you confirm the data you are receiving twice is the same? This will help me pinpoint the exact issue you are experiencing.

Thanks,

@bea91
Copy link
Author

bea91 commented May 18, 2017

Hi,

We have tested again the issue and we found out that branch init session call after the resume event was the problem.

As it is said in the documentation of Ionic 2/3 we have implemented branch init session after resume event like this:
platform.resume.subscribe(() => {
branchInit();
});

If branch init session is called after the resume event, deep links are received twice. After removing branch init session after resume event, deep links are received only once in background. So now is not needed to init session again after resume event. Can you please confirm this, and update the documentation? Thanks in advance.

We have tested also without internet connection. In these case, requests are not queued.

Best regards,
Bea

@ethanneff
Copy link
Contributor

ethanneff commented May 26, 2017

Hello,

Thanks for following up on this. I rebuilt our internal testing app for Ionic 2 and 3 and created some small sample apps. However, no one on my team is able to replicate the double deep link data on iOS.

The reason why we recommend our partners include the following is because deep link data will not pass through on Android whenever the app is background.

    platform.resume.subscribe(() => {
      branchInit();
    });

You can probably contain do the following to prevent your use case of double deep link data on iOS.

    platform.resume.subscribe(() => {
      if (platform.is('android')) { 
         branchInit();
      }
    });

In the meantime, we will keep an eye out for any others reporting this issue.

Thanks,

@pallaviashim
Copy link

pallaviashim commented Sep 28, 2017

Hello,

We have our iOS app. And I can link our app from our online site in chrome. But when i run the app again, the branch api returns the same params when it deep linked. I guess this is one of the problem that is mentioned in this thread. Do you have any solution?

Edited:
Found that the first time deeplink handler is getting fired twice. When first time it fires, the params doesnt have the key "_branch_match_id" and on going background and coming up they are sending params with "_branch_match_id".

Also i noticed that the handler method getting called twice in some cases. In that case too, the "_branch_match_id" is missing in the first and the second time they are sending the full keys.

@ethanneff - Did you notice this kind of thing any time?

Thanks

@ethanneff
Copy link
Contributor

Hello @pallaviashim, I pushed a fix yesterday (v2.6.14) to address this issue, can please update your Branch Cordova SDK to see if it fixes it?

@pallaviashim
Copy link

Sorry. I didnt mention, i am using branch api for native iOS. :-/ .

@nickpetrov
Copy link

nickpetrov commented Oct 12, 2017

@ethanneff Hey. Just re-checked data and the hotfix you've implemented. This doesn't solve the issue.
You comparing the timestamp and previous timestamp. and run the code if they are not equal. but for some reason on iOS the code ran twice even with the same timestamps.

NOTE: this bug only happens on a cold start. if the app is already running in background - deeplinks handler fired only once, as expected.

@ethanneff ethanneff reopened this Oct 12, 2017
@ethanneff
Copy link
Contributor

Hello @nickpetrov,

Ionic 1 & 2 are odd as their own device event handling gets duplicated on iOS resume. This behavior is the opposite behavior from Cordova, PhoneGap, and Ionic 3.

This hotfix I pushed originally was meant to stop the double opens which were happening (causing analytical discrepancies in the Brach Dashboard).

I've looked into this issue again and was unable to reproduce the error. Please make sure you have updated your Branch SDK. Furthermore, you want to make sure you are using branch.initSession() to read you deep link data and not the depreciated DeepLinkHandler() method.

Thanks,

@ravi-pandit14
Copy link

@ethanneff , initsession() did not fire when app is installed from app store. In ionic cordova build ios command xcode deploy on mobile its running fine. what is the problem??

@ethanneff
Copy link
Contributor

@ravi-pandit14, Make sure you have branch.initSession() in both deviceready and resume. https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking#initialize-branch

Additionally, make sure you follow the flow of a user. Deep link click -> app store -> install -> open -> read branch.initSession().

Lastly, branch.initSession() will not be called if there is a mismatch between deep link click and app open. The best way to test your configuration is by following this guide https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking#test-deep-link-ios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants