android-branch-deep-linking-attribution
android-branch-deep-linking-attribution copied to clipboard
Session initialization already happened. To force a new session, set intent extra, "branch_force_new_session",
I am getting branch deep link from a push notification. When i get branch deep link from notification, i pass it to the browser, it executes the deep link, and re-opens the app, this time i have branch data, that i use to launch specific screen.
I am using branch 5.0.1
The issue is that i am getting following error message, not every time but most of the times, when opening branch link from push notification. In other cases it just works fine.
_"Session initialization already happened. To force a new session, set intent extra, "branch_force_new_session"
Following is my code.
class SplashActivity : AppCompatActivity(), , Branch.BranchReferralInitListener{
override fun onStart() {
super.onStart()
Branch.sessionBuilder(this).withCallback(this).withData(this.intent?.data).init()
}
override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) this.intent = intent Branch.sessionBuilder(this).withCallback(this).reInit() }
override fun onInitFinished(referringParams: JSONObject?, error: BranchError?) {
if (error == null) {
if(referringParams?.has("news") ==true){
isNewsItemReceivedFromBranch = true
branchAggregatedFeedItemId = referringParams.getInt("news")
}
initAppStartupProcesses()
} else {
initAppStartupProcesses()
}
}
}
did you fixed this problem ?
As mentioned in #839
I am getting this error when I init Branch in a coroutine on Activity onStart()
uiScope.launch {
initBranchSession(this, uri)
}
private suspend fun initBranchSession(activity: Activity, uri: Uri?): Uri? {
return suspendCancellableCoroutine<Uri?> { cont ->
Branch.sessionBuilder(activity)
.withCallback { referringParams, error ->
if (error != null) {
Timber.e("Branch Init error = ${error.message}")
cont.resume(null)
} else if (referringParams != null) {
cont.resume(null)
} else {
cont.resume(null)
}
}
.withData(uri)
.init()
}
}
The same seems to work fine if we just remove init from a coroutine. What can be the reason for this behavior.
Any updates?
We are having the same warning message when switching the Mainactivity to the foreground. Waiting for updates. Thanks.