我已经实现了 iOS 和 Android SDK,现在我正在测试环境中测试我的应用配置。虽然在 iOS 上一切正常,但我注意到在 Android 上,该install
事件正确归因于我的快速链接,我发送的任何其他事件(即使我可以在实时视图中正确看到它们)都没有归因于用于打开应用程序的快速链接。
这是我的依赖项:
com.android.tools.build:gradle:3.1.1
com.google.gms:google-services:4.2.0
io.fabric.tools:gradle:1.31.0
com.android.support:appcompat-v7:28.0.0
这里的主要代码行:
@Override
protected void handleOnStart() {
super.handleOnStart();
Branch.enableDebugMode();
// Branch object initialization
Branch.getAutoInstance(this.getActivity().getApplication());
branchInstance = Branch.getInstance();
branchInstance.disableTracking(trackingDisabled);
branchInstance.initSession(new Branch.BranchReferralInitListener() {
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error != null) {
log("onInitFinished - " + error.getMessage());
} else {
log("onInitFinished invoked with " + referringParams.toString());
testEvent();
// Retrieve deeplink keys from 'referringParams' and evaluate the values to determine where to route the user
// Check '+clicked_branch_link' before deciding whether to use your Branch routing logic
}
}
}, getActivity().getIntent().getData(), getActivity());
}
@Override
public void onNewIntent(Intent intent) {
this.setIntent(intent);
}
private void testEvent() {
BranchEvent event = new BranchEvent(BRANCH_STANDARD_EVENT.VIEW_ITEM);
event.logEvent(this.getActivity());
}
我的 AndroidManifest.xml 看起来像这样:
<application android:launchMode="singleTask" .....>
<meta-data android:name="io.branch.sdk.BranchKey" android:value="@string/branchio_key_live" />
<meta-data android:name="io.branch.sdk.BranchKey.test" android:value="@string/branchio_key_test" />
<meta-data android:name="io.branch.sdk.TestMode" android:value="@bool/branchio_test_mode" />
<receiver android:enabled="@bool/branchio_track_referral_active" android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</application>