BranchMetrics / cordova-ionic-phonegap-branch-deep-linking-attribution

The Branch Cordova Ionic Phonegap SDK for deep linking and attribution. Branch helps mobile apps grow with deep links / deeplinks that power paid acquisition and re-engagement campaigns, referral programs, content sharing, deep linked emails, smart banners, custom user onboarding, and more.
https://docs.branch.io/apps/cordova-phonegap-ionic/
MIT License
234 stars 144 forks source link

Conflict with Facebook plugin on iOS #478

Closed sebaferreras closed 5 years ago

sebaferreras commented 6 years ago

Hello!

In our app we need to support both universal links (like https://foo.app.link/bar?campaign=95) and the old deep links (like foobar://campaign/95).

Universal links are working great for both Android and iOS.

When we open a deep link on Android, the Branch plugin shows that deep link in a property called +non_branch_link, which is expected, so this scenario is working fine as well.

branch android

But this does not work well on iOS, because of a conflict with the Facebook Cordova plugin. In the screenshot below, you can notice that the Facebook plugin gets the deep link information, prints a log in the console, and then for some reason the Branch plugin is not being able to get that deep link anymore and the +non_branch_link is empty:

not working

If I comment that openURL method (since we use Facebook only for tracking some in-app events, but not for allowing users to login, where I guess that openURL event is used) I can confirm that the Branch plugin is being able to get the +non_branch_link property with the deep link:

working

I'm not familiar with iOS native development at all, so maybe there's something in the way the Facebook plugin handles the deep link that causes the issue and it's obvious, but unfortunately I'm not being able to understand what's going on there.


Steps to reproduce the issue:

  1. Clone the Branch ionic3 example app from its repo
  2. Install the Facebook Cordova plugin (don't need to initialize anything, by just installing the Facebook plugin you can reproduce the issue)
  3. Paste the deep link (something like urischeme://foo/1234) in Apple Notes
  4. Long press on the deep link (not 3D Touch). Click Open in "APP_NAME" to open your app
KlaatuVerataNecto commented 6 years ago

Yeah, this is one very annoying.

ghost commented 6 years ago

Can confirm the issue as well.

sequoiaat commented 6 years ago

Hi,

@sebaferreras Can you please mention the version that you're using? Like,

  1. branch SDK version
  2. Facebook plugin version
  3. Cordova/ionic versions

Thanks

sebaferreras commented 6 years ago

@sequoiaat of course! We're using:

branch-cordova-sdk: 3.0.0
cordova-plugin-facebook4: 2.2.0
// Ionic info

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.10
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    ios-sim           : 5.0.8
    Node              : v8.11.1
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.4.1 Build version 9F2000
sequoiaat commented 6 years ago

@sebaferreras We are not seeing the issue, non-branch link is not empty. Followed your steps and made sure exact version no.s of all packages. We just installed Facebook cordova plugin. Are you sure no need to initialize it?

Thanks

sebaferreras commented 6 years ago

@sequoiaat are you testing that on an iOS device? Because it works properly on Android, but not for iOS

sequoiaat commented 6 years ago

@sebaferreras Yes, iOS device

sebaferreras commented 6 years ago

@sequoiaat is there any way that I can access to that test project, in order to see if I can reproduce the issue with it? If not, please let me know and I'll create a demo using a new branch account and a new facebook app and I'll give you access to that repo.

sequoiaat commented 6 years ago

@sebaferreras
We tried to reproduce it in the example app(https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/tree/master/examples/ionic3) and added the Facebook Cordova plugin into it. It will be great if you could share your demo app.

sebaferreras commented 6 years ago

@sequoiaat I'm very sorry for such a delay, today I'll create a demo app so you can reproduce the issue on your end. Thanks.

sebaferreras commented 6 years ago

@sequoiaat I've created this Github project where you can reproduce the issue.

I've also recorded the following video using that project where you can see how I was able to reproduce the issue and then I was able to fix it by commenting a method from the Facebook plugin: https://www.dropbox.com/s/o4i7k2zbdigdabo/Branch%20Issue.mov?dl=0

ionic info

Ionic:

   ionic (Ionic CLI)  : 4.0.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.9

Cordova:

   cordova (Cordova CLI) : 7.1.0
   Cordova Platforms     : ios 4.5.4

System:

   Android SDK Tools : 26.1.1
   ios-deploy        : 1.9.2
   ios-sim           : 5.1.0
   NodeJS            : v8.11.1 (/usr/local/bin/node)
   npm               : 5.10.0
   OS                : macOS High Sierra
   Xcode             : Xcode 9.4.1 Build version 9F2000

Environment:

   ANDROID_HOME : /Users/sebastian/Developer/Android/
sequoiaat commented 6 years ago

@sebaferreras We are unable to reproduce this issue after following the exact steps your mentioned. The only difference we had was we were using the latest versions. Can you please try with the branch SDK version 3.0.1 and Facebook SDK version 2.4.0 instead of 2.2.0

paulstelzer commented 6 years ago

@sebaferreras did you get it working now on iOS? I think they have an issue there

sequoiaat commented 6 years ago

@sebaferreras @paulstelzer We are working on this for a possible solution as we were able to reproduce this issue.

sequoiaat commented 6 years ago

@sebaferreras @paulstelzer - We have been able to trace the issue down . When using FacebookPlugin, it is not triggering AppDelegate+BranchSdk.m class. It goes to FacebookConnectPlugin.m class openURl() and directly enters into Cordova AppDelegate Methods which is why it fails . We are trying to handle this and release a fix

sebaferreras commented 6 years ago

Thank you so much for your support @sequoiaat!

noahcooper commented 6 years ago

Any update on this?

sequoiaat commented 6 years ago

@noahcooper @sebaferreras @paulstelzer . We have pushed a PR to fix this issue . Once tested and approved it should solve the problem. - this is the PR https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/pull/521

sequoiaat commented 5 years ago

@sebaferreras @paulstelzer Can we close this one as @sean-browze confirmed that the new role out addressed this issue.

csalmi-branch commented 5 years ago

@sebaferreras Are you still experiencing this issue?

sebaferreras commented 5 years ago

@sequoiaat, @csalmi-branch I'll be testing this today/tomorrow and will get back to you. Thanks!

faisalcom commented 5 years ago

same issue until now its conflict

csalmi-branch commented 5 years ago

@faisalcom Could you please explain your statement? Does this fix not work for you?

csalmi-branch commented 5 years ago

@sebaferreras and @faisalcom, if you are still experiencing this issue, could you please let us know which version you are using?

csalmi-branch commented 5 years ago

I am closing this issue. If a problem still is occurring, please submit a support ticket or open a new issue.