[英]how to implement Facebook sharing and then deep link that post using deep link(open my app) in android App?
I want to implement deep linking for facebook app post. 我想为Facebook应用发布实现深层链接。 Firstly I want to share my App content on Facebook Post and when user tap on the post then if User already has the app installed then open app otherwise It will open app link.
首先,我想在Facebook Post上分享我的App内容,然后当用户点击该Post时,如果用户已经安装了该App,则打开app,否则将打开App链接。
I follow https://developers.facebook.com/docs/applinks/android and https://developers.facebook.com/docs/sharing/android#linkshare but It's not working 我遵循https://developers.facebook.com/docs/applinks/android和https://developers.facebook.com/docs/sharing/android#linkshare但它无法正常工作
how to share this data using LinkShare on facebook 如何在Facebook上使用LinkShare共享此数据
target_url: " https://developers.facebook.com/android " extras: fb_app_id: [YOUR_FACEBOOK_APP_ID] fb_access_token: "[ACCESS_TOKEN]" fb_expires_in: 3600 target_url:“ https://developers.facebook.com/android ”额外功能:fb_app_id:[YOUR_FACEBOOK_APP_ID] fb_access_token:“ [ACCESS_TOKEN]” fb_expires_in:3600
To implement deep linking and sharing together, need to implement this feature using branch.io 要一起实现深度链接和共享,需要使用branch.io实现此功能
Add dependency : 添加依赖项:
compile 'com.google.android.gms:play-services-appindexing:9.+'
Add this code in the manifest file inside Launcher Activity 将此代码添加到Launcher活动内的清单文件中
<!-- Branch URI Scheme -->
<intent-filter>
<data android:scheme="androidexample" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<!-- Branch App Links (optional) -->
<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="example.app.link" />
<data android:scheme="https" android:host="example-alternate.app.link" />
</intent-filter>
Add this code to your Launcher Activity, You will get your link and data in this method 将此代码添加到启动器活动中,您将通过此方法获取链接和数据
@Override
public void onStart() {
super.onStart();
// Branch init
Branch.getInstance().initSession(new Branch.BranchReferralInitListener() {
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
Log.i("BRANCH SDK", referringParams.toString());
// 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
} else {
Log.i("BRANCH SDK", error.getMessage());
}
}
}, this.getIntent().getData(), this);
}
Add this code in MyApplication class 将此代码添加到MyApplication类中
// Branch logging for debugging
Branch.enableLogging();
// Branch object initialization
Branch.getAutoInstance(this);
You can create deep link using this code 您可以使用此代码创建深层链接
LinkProperties lp = new LinkProperties()
.setChannel("facebook")
.setFeature("sharing")
.setCampaign("content 123 launch")
.setStage("new user")
.addControlParameter("$desktop_url", "http://example.com/home")
.addControlParameter("custom", "data")
.addControlParameter("custom_random",
Long.toString(Calendar.getInstance().getTimeInMillis()));
buo.generateShortUrl(this, lp, new
Branch.BranchLinkCreateListener() {
@Override
public void onLinkCreate(String url, BranchError error) {
if (error == null) {
Log.i("BRANCH SDK", "got my Branch link to share: " + url);
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.