问题
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
回答1:
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:
- App Links - when using App Links (native Android deep linking, supported on Android 6+), the deep link data is found within the intent that started the Launcher activity. In this scenario, unless you handle the intent manually, the data would no longer be accessible if you start another activity without initializing the Branch SDK first.
- Branch analytics attribution - the intent that started the Launcher activity might contain data that indicates where the app was launched from (could be a push notification, Play Store listing, etc.)
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
.
回答2:
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.
来源:https://stackoverflow.com/questions/51248310/branch-io-android-sdk-only-initialize-branch-in-the-launcher-activity-and-g