【发布时间】:2017-05-07 21:52:19
【问题描述】:
请参阅下面的两个链接。粘贴到 Whatsapp 时,第一个用 Facebook 应用打开,第二个用浏览器打开。
在 Facebook 应用中打开:
https://m.facebook.com/SriSwamiji/posts/1099353043449548:0
在浏览器中打开:
是什么让第二个链接在浏览器中打开? 我想通过 Facebook 应用打开它。
【问题讨论】:
请参阅下面的两个链接。粘贴到 Whatsapp 时,第一个用 Facebook 应用打开,第二个用浏览器打开。
在 Facebook 应用中打开:
https://m.facebook.com/SriSwamiji/posts/1099353043449548:0
在浏览器中打开:
是什么让第二个链接在浏览器中打开? 我想通过 Facebook 应用打开它。
【问题讨论】:
我会说这是由于deep linking。在您的任何应用中,您都可以添加过滤器,以便在 Android 系统尝试解析 URL 时触发您的应用。
可能是 Facebook 应用配置了http://m.* url 的深层链接
编辑:我已经通过 adb 对其进行了测试,这是由于深度链接造成的。您可以使用
进行测试adb shell am start -W -a android.intent.action.VIEW -d <URL>
如the deep link documentation中所述
这是输出:
$ adb shell am start -W -a android.intent.action.VIEW -d "https://m.facebook.com/SriSwamiji/posts/1099353043449548:0"
Starting: Intent { act=android.intent.action.VIEW dat=https://m.facebook.com/... }
Status: ok
Activity: com.facebook.katana/com.facebook.deeplinking.activity.StoryDeepLinkLoadingActivity
ThisTime: 127
TotalTime: 208
WaitTime: 253
Complete
如您所见,启动的Activity 是com.facebook.katana(Facebook 应用程序)。
$ adb shell am start -W -a android.intent.action.VIEW -d "https://www.facebook.com/SriSwamiji/photos/a.186720728046122.67368.108460819205447/1099353043449548/?type=3"
Starting: Intent { act=android.intent.action.VIEW dat=https://www.facebook.com/... }
Status: ok
Activity: com.android.chrome/org.chromium.chrome.browser.document.DocumentActivity
ThisTime: 121
TotalTime: 179
WaitTime: 223
Complete
在这种情况下com.android.chrome 启动
此外,如果您查看 Facebook 应用清单(对于某些应用,例如 ManifestViewer,您可以看到它有一些 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="http"
android:host="m.facebook.com"
android:pathPrefix="/events"/>
<data
android:scheme="https"
android:host="m.facebook.com"
android:pathPrefix="/events"/>
<data
android:scheme="http"
android:host="m.facebook.com"
android:pathPrefix="/groups"/>
<data
android:scheme="https"
android:host="m.facebook.com"
android:pathPrefix="/groups"/>
<data
android:scheme="http"
android:host="www.facebook.com"
android:pathPrefix="/groups"/>
<data
android:scheme="https"
android:host="www.facebook.com"
android:pathPrefix="/groups"/>
<data
android:scheme="http"
android:host="www.facebook.com"
android:pathPrefix="/events"/>
<data
android:scheme="https"
android:host="www.facebook.com"
android:pathPrefix="/events"/>
</intent-filter>
在您的具体情况下,我会说该链接是在
中处理的 <activity
android:theme="@2131625627"
android:name="com.facebook.katana.ContactUriHandler"
android:taskAffinity="com.facebook.task.ContactUriHandler"
android:excludeFromRecents="true"
android:launchMode="singleInstance">
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<data
android:mimeType="vnd.android.cursor.item/vnd.facebook.profile"
android:host="com.android.contacts"/>
<data
android:mimeType="vnd.android.cursor.item/vnd.facebook.presence"
android:host="com.android.contacts"/>
</intent-filter>
</activity>
内部支持帖子但不支持照片
【讨论】:
https://www.facebook.com/pg/companyname/home for Android,https://www.facebook.com/pg/companyname for iOS 和简单的@987654337 @ 适用于所有其他平台。