gpt4 book ai didi

java - initbranch.io 出现问题

转载 作者:太空宇宙 更新时间:2023-11-04 10:58:17 26 4
gpt4 key购买 nike

我使用branch.io 来处理应用程序链接。 AndroidManifest 有针对 Branch URI 方案的 Intent 过滤器:

<intent-filter>
<data android:scheme="***" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

AndroidManifest 还具有应用程序链接的 Intent 过滤器:

<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="***.app.link" />
<data
android:host="***-alternate.app.link"
android:scheme="https"/>
<data
android:host="***.test-app.link"
android:scheme="https"/>
<data
android:host="***-alternate.test-app.link"
android:scheme="https"/>

AppLinkActivity 的启动模式为 singleTask。我在 onCreate 中的应用程序中初始化分支:

Branch.getAutoInstance(this);

打开 AppLinkActivity 后,我获取实例并初始化 session :

Branch branch = Branch.getInstance(getApplicationContext());
branch.initSession((referringParams, error) -> {
LogFileUtil.writeLog("Finish init session");
if (error == null) {
//Кое что делаю
} else {
//Кое что делаю
}
}, this.getIntent().getData(), this);

当我通过 AppLink 打开我的应用程序时,referencingParams 不为空。我可以获得所需的数据。但是,当应用程序打开并且我从其他应用程序单击 AppLink 时,referencingParams 为空。我认为问题出在 init 分支上。我该如何修复它?

最佳答案

您需要确保重写 AppLinkActivity 中的 onNewIntent() 方法。这将确保返回相同的 Intent 。

将以下代码段添加到您的 AppLinkActivity:

@Override
protected void onNewIntent(Intent intent) {
this.setIntent(intent);
}

关于java - initbranch.io 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47152114/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com