如何在 android 应用程序中使用深度 link(打开我的应用程序)实现 Facebook 共享然后深度 link 那 post?

how to implement Facebook sharing and then deep link that post using deep link(open my app) in android App?

我想为 Facebook 应用 post 实施深度 linking。 首先,我想在 Facebook Post 上分享我的应用程序内容,当用户点击 post 时,如果用户已经安装了该应用程序,则打开应用程序,否则它将打开应用程序 link。

我关注 https://developers.facebook.com/docs/applinks/android and https://developers.facebook.com/docs/sharing/android#linkshare 但它不起作用

如何在 Facebook 上使用 LinkShare 分享这些数据

target_url: "https://developers.facebook.com/android" 演员: fb_app_id: [YOUR_FACEBOOK_APP_ID] fb_access_token:“[ACCESS_TOKEN]” fb_expires_in: 3600

要同时实现深度 link 共享和共享,需要使用 branch.io

实现此功能

添加依赖项:

 compile 'com.google.android.gms:play-services-appindexing:9.+' 

在 Launcher 内的清单文件中添加此代码 Activity

  <!-- 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>    

将此代码添加到您的启动器 Activity,您将在此方法中获取您的 link 和数据

@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);
}    

在我的应用程序中添加此代码class

 // Branch logging for debugging
    Branch.enableLogging();

 // Branch object initialization
    Branch.getAutoInstance(this);   

您可以使用此代码创建深度 link

 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);
    }
}
});    

refer this for Android

refer this for ios