This has only been confirmed on Android so far with 2.0. To reproduce:
The params returned in the subscribe method include a +non_branch_link that may or may not be a Branch link. This parameter is returned by the native Android SDK. However, the problem is not reproducible with the Android SDK directly. It's probably caused by some state in the RN codebase.
Output from logcat with webview_example: https://gist.github.com/jdee/cf8b1902e1b9d071dad8c48b44a6523e
This behavior is consistent when testing with react-native-branch 2.0
If you can reproduce this in any other situation, please comment and include:
FYI, got the same issue on Android, with react-native-branch 2.0.0-beta...
I cannot really give detailed step to reproduce, as ATM it seems that it always fails (i.e. every clicked branch link is considered by the sdk as a non-branch-link).
I have a similar issue when using the test key. If I have #ifdef DEBUG [RNBranch useTestInstance] in my AppDelegate.m uncommented, it would use my test key as it's supposed to, but I'll get "+non_branch_link" every time. Once I comment that out, the branch data comes thru successfully using the live key.
It would be nice to use the test key and have branch.subscribe register that the clicked link is in fact a branch link
@bporter2387 That sounds like an issue with the configuration of the test instance.
Some things to check:
myapp.test-app.link and myapp-alternate.test-app.link to your associated domains entitlement (iOS) and manifest (Android).This can also be automatically set up and validated using Fastlane and the branch plugin. See the examples in this repo, e.g. webview_example, for use with React Native.
Noticing this issue on Android, doesn't happen on iOS. Noticed this issue when I tried to setup Android App Links. When I click the link it takes me to the app, but every time I put the app in the background and open the app up again, it will re-trigger branch.subscribe
log: this same log will show three times as well. Actually I'm noticing in some cases the amount of times Added the call to unsubscribe on branch.subscribe seems to growcomponentWIllUnmount and it seems to prevent this issue.
09-07 13:26:49.290 23623 23701 I ReactNativeJS: { error: null,
09-07 13:26:49.290 23623 23701 I ReactNativeJS: uri: 'https://www.android_app_link.com/test/me',
09-07 13:26:49.290 23623 23701 I ReactNativeJS: params:
09-07 13:26:49.290 23623 23701 I ReactNativeJS: { '+is_first_session': false,
09-07 13:26:49.290 23623 23701 I ReactNativeJS: '+clicked_branch_link': false,
09-07 13:26:49.290 23623 23701 I ReactNativeJS: '+non_branch_link': 'https://www.android_app_link.com/test/me' } }
react-native: 0.47.2
react: 16.0.0-alpha.12
react-native-branch: 2.0.0-beta.7
@jdee is there an update with this bug?
Apologies for the long delay. It took a while to find the smoking gun(s). I can reproduce this problem in other environments (native Android and iOS apps) without RN. It may be a server issue, though I'm not sure at the moment. Branch is working on it. The good news is, if it's a server issue, it should just go away with no action on your part.
The subscribe callback is invoked at times other than link opens. Often you'll get { "+clicked_branch_link": false, "+is_first_session": false }. Generally this means the SDK checked for a deferred deep link and found nothing. It's necessary to check the +clicked_branch_link parameter anyway. If you're only using Branch links, then that's all you really need to do. If you're also using non-Branch links with the Branch SDK, then you also need to check the +non_branch_link field, and this will be broken for you right now.
Regarding where to call the subscribe method, the important thing is that it needs to be called at app launch and remain in place throughout the lifetime of the app. We've been recommending componentDidMount in the root component for this, but perhaps there is a better place.
See the examples in this repo, particularly App.js in the webview_example for recommended usage of branch.subscribe. Also see the new webview_tutorial app, which walks you step by step through adding Branch to a simple app.
Finally, in the future if you have problems like this, you'll undoubtedly get better results by opening a support ticket at https://support.branch.io or by emailing [email protected]. Branch has an excellent support team, and I assure you they'll get the job done for you. (Unlike me, it seems.)
@jdee thank you for your work! Also will definitely go with the support team next time.
This is addressed by a patch in the Android SDK: https://github.com/BranchMetrics/android-branch-deep-linking/pull/484. It fixes the problem in testing with webview_example. When the next release of Android is available, a patch will be released here with that update. Thanks for your patience.
The fix for this is in the master branch with Android 2.12.2. I'll release this as 2.1.1 after I have a chance to test it, probably tomorrow morning.
Fixed in 2.1.1, which was released to NPM.
Most helpful comment
Noticing this issue on Android, doesn't happen on iOS. Noticed this issue when I tried to setup Android App Links. When I click the link it takes me to the app, but every time I put the app in the background and open the app up again, it will re-trigger
branch.subscribelog: this same log
will show three times as well. Actually I'm noticing in some cases the amount of timesAdded the call to unsubscribe onbranch.subscribeseems to growcomponentWIllUnmountand it seems to prevent this issue.react-native: 0.47.2
react: 16.0.0-alpha.12
react-native-branch: 2.0.0-beta.7