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,
From the same document that you linked above:
Enable / Disable User Tracking
If you need to comply with a user's request to not be tracked for GDPR purposes, or otherwise determine that a user should not be tracked, utilize this field to prevent Branch from sending network requests. This setting can also be enabled across all users for a particular link, or across your Branch links.
Branch.getInstance().disableTracking(true);
You can choose to call this throughout the lifecycle of the app. Once called, network requests will not be sent from the SDKs. Link generation will continue to work, but will not contain identifying information about the user. In addition, deep linking will continue to work, but will not track analytics for the user.
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 of onStart
. 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 from onCreate
.
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.