According to the doc: https://docs.branch.io/pages/apps/android/ :
"Only initialize Branch in the Launcher activity The app will open through the Launcher activity, where Branch will initialize and retrieve the deep link data from the link click."
My problem is that I have got a GDPRLauncherActivity that is the launcher activity of my project. This GDPR activity is displayed to EU users at first launch and never displayed anymore later (the GDPRLauncherActivity directly launches my mainActivity), and never displayed to the users outside the EU (the GDPRLauncherActivity will also directly launch my mainActivity).
I don't want to initialize Branch in my GDPRLauncherActivity as it would not be GDPR compliant (the user needs to give its agreement first).
My question is : is it be really a problem if I initialize Branch in my MainActivity (and not my GDPRLauncherActivity that is not my launcher activity). I think that it is a problem because this.getIntent() will not get the correct content (and because it is written in the doc :) )
So: is it a problem ? If yes, what is the easiest workaround ?
Thanks
From the same document that you linked above:
This should allow you to focus on the deep linking functionality without having to worry about user tracking, as you can add separate logic for disabling it. Also, Branch doesn't collect any PII (personally identifiable information) just because of you integrating the SDK. You would have to manually set user IDs and report user events through the Branch.io SDK.
Branch asks for the SDK to be initialized within the Launcher activity for a few different reasons:
If you are not using App Links, you can safely initialize the SDK in the MainActivity. Also, since you are not initializing it within the Launcher activity, it's probably a good idea to do it within the
onCreate
method of MainActivity, instead ofonStart
. This means you would only consume network data when the MainActivity is loaded the first time - backgrounding and foregrounding the app would not trigger it again. All of the deep links would trigger the Launcher activity anyway, which in turn would open MainActivity, at which point the SDK would be initialized fromonCreate
.Jackie from Branch here.
As a rule of thumb, initializing the Branch SDK in the Launcher Activity is critical for attribution and is a mandatory step. Without this, the Branch SDK will not be able to report installs, opens or any other down the funnel events and hence you will not get any attribution data on the Branch dashboard.
That being said, in your case, I'd recommend setting
Branch.trackingDisabled = YES
at the beginning and then initializing Branch after. When a user opts in for tracking,Branch.trackingDisabled = NO
will be called, and the Branch SDK will operate as normal. Installs will be missing for this approach unless the user opts in within the first app open.If you have additional questions, please email directly at integrations@branch.io.