gpt4 book ai didi

android - 在 Android 中安装应用程序后,Facebook 深层链接永远不会返回数据

转载 作者:行者123 更新时间:2023-11-29 14:18:04 71 4
gpt4 key购买 nike

当我点击发布在 FB 上的深层链接时,我尝试使用 FB 深层链接 在安装应用程序后获取推荐信息。但只有在应用已安装的情况下,我才会收到深层链接数据。

按照这个文档 https://developers.facebook.com/docs/applinks/android

应用程序应在安装应用程序后从深层链接接收数据。但 native FB 应用程序仅发送到 GooglePlay:

market://details?id=my.app.package&referrer=utm_source=apps.facebook.com&utm_campaign=fb4a&utm_content=%7B%22app%22%3A0%2C%22t%22%3A1436879844%7D

没有来自深层链接的信息

第一次启动我尝试在我的启动屏幕中使用下一个方法

AppLinks.getTargetUrlFromInboundIntent

AppLinkData.fetchDeferredAppLinkData但他们让我无效。

一步一步

  1. 我已经为 android 创建了托管的 api 链接。哪里包括 android https://developers.facebook.com/docs/graph-api/reference/v2.0/app/app_link_hosts 的所有可能数据
  2. 然后通过 FB SDK 发布此链接。
  3. 删除我的申请
  4. 在 native FB 应用程序中单击带有深层链接的我的帖子
  5. FB 让我安装应用程序。我已经从 GooglePLay 安装了应用

预期:安装后在启动应用程序时接收深层链接数据。

但是如果使用 FB Docs 中描述的方法我没有收到任何信息

最佳答案

请注意,我帮助构建了 Branch ( branch.io),这是一种链接工具,可帮助通过 Play 商店进行深度链接。让 Facebook 的方法也可靠地工作,我们遇到了很多麻烦。如果您使用 Branch 深层链接来托管您的 Facebook 应用链接,它会在 100% 的时间内通过页面帖子、广告和邀请工作。我们有一个服务器到服务器与 Facebook 的集成,但如果失败,我们会回退到我们的指纹识别机制,我们将浏览器指纹与设备指纹进行匹配。 (更多关于 here )

这里描述了如何进行设置,以便 Branch 通过安装托管您的 Facebook 应用程序链接和深层链接:

  1. 前往start.branch.io获取您的分支 key 并配置您的链接路由
  2. 从 Maven Central 添加 io.branch.sdk.android
  3. 为深层链接设置您的 list 。你将从这里开始:
<application>
<!-- Other existing entries -->
<activity
android:name="com.yourapp.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
  • 添加应用程序子类,以便 Branch 可以监控生命周期变化以检测新的深层链接。
<application
android:name="io.branch.referral.BranchApp">
  • 添加您的 Intent 过滤器以在应用已安装时接收深层链接
<intent-filter>
<data android:scheme="yourapp" 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>
  • 添加您的分支 key
<meta-data android:name="io.branch.sdk.BranchKey" android:value="your_key_here" />

最终的 list 应该是这样的:

<application
android:name="io.branch.referral.BranchApp">

<!-- Other existing entries -->
<activity
android:name="com.yourapp.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="yourapp" 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>
</activity>

<meta-data android:name="io.branch.sdk.BranchKey" android:value="your_key_here" />

</application>
  1. 注册以接收来自 Branch 深层链接点击的参数。这通常放在要用于深度链接路由的 Activity 的 onStart 中。
Branch branch = Branch.getInstance(getApplicationContext());
branch.initSession(new BranchReferralInitListener(){
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
// ... insert custom logic here ...
} else {
Log.i("MyApp", error.getMessage());
}
}
}, this.getIntent().getData(), this);
  1. 最后,您可以通过 100 种不同的方式创建 Branch 托管的 Facebook 应用程序链接。以下是如何从您的应用动态创建它们:
Branch branch = Branch.getInstance();
JSONObject obj = new JSONObject(); obj.putString("foo", "bar");
branch.getShortUrl(obj, "sms", "share", new BranchLinkCreateListener() {
@Override
public void onLinkCreate(String url, BranchError error) {
Log.i("MyApp", "Ready to share my link = " + url);
}
});

链接愉快!

关于android - 在 Android 中安装应用程序后,Facebook 深层链接永远不会返回数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31422738/

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