简体   繁体   中英

App link not working for facebook on android

Facebook app link is not working. link contains the following:

<html>
    <head>
    <meta property="al:android:url" content="myapp://12345" />
    <meta property="al:android:package" content="com.my.app" />
    <meta property="al:android:app_name" content="myApp" />
    <meta property="al:web:should_fallback" content="false" />
    </head>
</html>

Androidmanifest is like the following:

<activity
 android:name="com.my.app.MyAppActivity" 
 android:launchMode="singleTask"
   <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
   <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="myapp" />
</intent-filter>

Meta property in the html should be responsible for launching intent from the Facebook app but opening the link through facebook doesn't launch the application. Where I am getting wrong?

This how App Link working for me to share with friends via Facebook or other sharing intent.

Share Intent Code

Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Lets Enjoy");
intent.putExtra(Intent.EXTRA_TEXT, "Lets Enjoy" + "http://myApp.com/id/"+12345);
startActivity(Intent.createChooser(intent, "Share With Friends")); 

Android Manifest.

 <activity
        android:name="com.package.youractivitytoopen"
        android:theme="@style/MyMaterialTheme"
        android:screenOrientation="portrait">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:scheme="http"
                android:host="myApp.com"
                android:pathPrefix="/id/" ></data>
        </intent-filter>
 </activity>

If you sharing data then you will get data like that

Intent intentShare = getIntent();
String action = intentShare.getAction();
Uri data = intentShare.getData();
if(data!=null) {
   String url = data.toString();
   String[] separated = url.split("/");
   id= Integer.parseInt(separated[4]);
}

Share with your friends via share intent if they have application it will show option to open with app and opened at the activity you set in manifest.

https://developer.android.com/training/app-indexing/deep-linking.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM