I checked this issue reported on git, many people reported it, but there was no proper solution available there.
It all works fine, if i app is killed and no process of app exists in memory.
But my use case is to get branch link from Push Notification.
I have also set splashActivity as SingleTask
android:launchMode="singleTask"
I am getting following error message.
BRANCH_SDK: Warning. Session initialization already happened. To force a new session, set intent extra, "branch_force_new_session", to true.
Following is my code, it checks if its there any data from branch, and pass the details to HomeActivity, HomeActivity then loads specific news item based on the id.
I don't know where to pass branch_force_new_session
this info. If i pass it from Splash Intent, it just does not work.
I am using branchSDK 5.0.1
class SplashActivity : AppCompatActivity(), , Branch.BranchReferralInitListener{
override fun onStart() {
super.onStart()
Branch.sessionBuilder(this).withCallback(this).withData(if (intent != null) intent.data else null).init()
Log.d("BRANCH_SDK_00_", "onStart")
}
override fun onInitFinished(referringParams: JSONObject?, error: BranchError?) {
if (error == null) {
if(referringParams?.has("news") ==true){
isNewsItemReceivedFromBranch = true
branchAggregatedFeedItemId = referringParams.getInt("news")
//StartHomeActivity()
}
initAppStartupProcesses()
} else {
Log.e("BRANCH_SDK", error.message)
initAppStartupProcesses()
}
}
}
Manifest
<activity
android:name=".activities.SplashActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Branch URI Scheme -->
<intent-filter>
<data android:scheme="aaa" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<!-- Branch URI Scheme -->
<!-- Branch App Links (optional) -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="aaa.aa.aa" />
<data android:scheme="https" android:host="aaa.aaaa" />
</intent-filter>
</activity>