android-branch-deep-linking-attribution: Launching deeplink from within the app returns empty referral parameters
- Create a valid deep-link URL
- Launch the URL from within the app:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(deepLinkUrl));
startActivity(intent);
- When
BranchReferralInitListener.onInitFinished(JSONObject referringParams, BranchError error)gets called when callingBranch.getInstance().initSession(),referringParamsis empty.
I have modified the Branchster sample app to demonstrate this in the following branch: https://github.com/carloshwa/Branch-Example-Deep-Linking-Branchster-Android/tree/launch_deep_link_from_app
Here is my change to the sample app to launch a deep-link from the app (tap your monster to launch a deep-link to my monster):
https://github.com/carloshwa/Branch-Example-Deep-Linking-Branchster-Android/commit/e06738f2598239b417fad0f2aa041e1aceb37c86
You can see branchUniversalObject in SplashActivity is null when the app is launched.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 35 (14 by maintainers)
I’m still facing this issue on v4.2.0 unfortunately. Tried everything on this thread. Funny thing is, this wasn’t an issue when my Branchl library was version ~2.0. Back then warm start launches were handled fine, but now only cold start launches work.
Hey @aaustin, in our app, we have a SplashActivity (here we handle the deeplinks) which leads to a HomeScreen and finishes itself.
With that premise, we cannot set our SplashActivity
launchModetosingleTaskbecause every time we launch the app (even if it’s already in background) it will launch from the scratch losing the state.Anyways, we tried to follow your directions and still doesn’t work. When
onNewIntentis called weinitSessionbutreferringParamsis still empty.intent.putExtra("branch_force_new_session",true);doesn’t work for us either, as we’re not opening the link from within the app, but from a push notification.So, just to clarify our issue:
SplashActivityis launched butreferringParamsis empty when weinitSessionIf the app is not in memory or It’s in background,
referringParamscontains the expected parameters so we can process the deeplink successfullyI got this working on 3.2.0 version and this implementation:
I still did not test this implementation thoroughly.
We released v3.1.1 of the SDK which has a fix for this issue.
Hi all, quick update here, we have the solution internally in place, we will be releasing the fix in an SDK update soon. Will update here once we do.
Hi @VvoidVano. Sorry that I forgot to post the update. We’ve determined that the SDK currently doesn’t receive the new link data in the following case only:
The problem is that the SDK doesn’t check the Intent in this case, because the Activity state doesn’t call onResume when it’s in foreground and a notification is clicked. Because it’s isolated to a rare edge case, we haven’t prioritized a fix but we’re looking into it this week actually. cc @apeterson-branch
Hey @ibracero - Can you post a link to you SplashActivity.java and manifest code that I could review? Perhaps share a gist? I guarantee it’s one of the above things that’s causing this. If you’re not comfortable sharing in the public thread so others can learn, please send a note to alex@branch.io with this info and I’ll work with you 1 on 1, then post the solve here.