android-branch-deep-linking-attribution
android-branch-deep-linking-attribution copied to clipboard
referringParams is not correct when app is in the background or when app is not open
Branch version: 5.0.15 android-sdk-ui:16.0.0
When app is in the background state or app is not open, the referringParams is not correct. App receive notification at that moment, it shows as below:
referringParams = {"+clicked_branch_link":false,"+is_first_session":false}
And then we can not navigate to the specific screen.
It works well when app is in the foreground state.
When app in the background or app is not open, there is a related log as below:
initializing session on user's behalf (onActivityResumed called but SESSION_STATE = UNINITIALISED)
Right now I have the exact same problem. Followed the documentation from top to bottom and sometimes params are empty.
Same happens to me
In my case, this was happening when opening the app from a push notification (cold start). I've noticed that, under this circumstance, Branch SDK was doing the POST request twice (I figured one by the lib and another one from the initSession call in activity's onStart). This may cause a confusion concerning which params gets delivered first, causing the inconsistent behavior.
So, In my case, setting expectDelayedSessionInitialization to true prior to initializing the instance solved the issue, cause then Branch waits for user to initialize the session:
For cold start:
private fun setupBranch() {
Branch.enableLogging()
Branch.expectDelayedSessionInitialization(true)
Branch.getAutoInstance(this)
}
And since Branch SDK seems to reset this value during initialization, it's necessary to call it again when app goes to background, in order to cover the app running in the background scenario:
override fun onPause() {
super.onPause()
Branch.expectDelayedSessionInitialization(true)
}
After doing that, no more empty params again.
@levyschiavetti thanks for the suggestion!
In my case, this was happening when opening the app from a push notification (cold start). I've noticed that, under this circumstance, Branch SDK was doing the POST request twice (I figured one by the lib and another one from the initSession call in activity's onStart). This may cause a confusion concerning which params gets delivered first, causing the inconsistent behavior.
So, In my case, setting expectDelayedSessionInitialization to true prior to initializing the instance solved the issue, cause then Branch waits for user to initialize the session:
For cold start:
private fun setupBranch() { Branch.enableLogging() Branch.expectDelayedSessionInitialization(true) Branch.getAutoInstance(this) }And since Branch SDK seems to reset this value during initialization, it's necessary to call it again when app goes to background, in order to cover the app running in the background scenario:
override fun onPause() { super.onPause() Branch.expectDelayedSessionInitialization(true) }After doing that, no more empty params again.
It worked perfectly after spending two days on the issue without any solution this was very helpful @levyschiavetti
Branch version: 5.0.15 android-sdk-ui:16.0.0
When app is in the background state or app is not open, the referringParams is not correct. App receive notification at that moment, it shows as below:
referringParams = {"+clicked_branch_link":false,"+is_first_session":false}And then we can not navigate to the specific screen.
It works well when app is in the foreground state.
Currently I am also facing the same issue with branch and Airship integration, have tried various solutions but nothing seems to work
@pd90, I'm assuming with Airship this is in regards to push notifications correct? If so, could you confirm you are properly adding the branch link as custom data to the push payload for the key"branch" and not utilizing the branch link as the action url of the push payload?