2016-12-16 160 views
0

我正在構建其中一個FB Messenger Bot應用程序,並且我想將我的應用程序自定義URL發送到Messenger的答覆中,以便用戶可以點擊它打開應用程序(該應用程序已經安裝在設備上)。這是應用程序不是在應用程序商店,現在只是一個演示。如何通過點擊自定義URL來打開我的Android應用程序?

使用圖形API發送,添加的按鈕:

https://developers.facebook.com/docs/messenger-platform/send-api-reference/url-button

我怎樣才能做到這一點?當我在URL負載中發送http://www.example.com時,它在WebView中打開,無法導航到安裝我的Android應用程序。

相同的網址http://www.example.com其他應用程序在我的應用程序中打開。 (出Android版Gmail應用程序)

感謝,

回答

1

@Suhas Bachewar,

要對其他應用程序打開的應用程序,你必須實現 deep-link

請找tutorial from here

下面的XML片段展示瞭如何實現深層鏈接,你可能必須指定在您的清單深層鏈接的意圖過濾器。

中的URI「yourapp://機器人」和「http://www.yourapp.com/droid」既解決這一活動。

接受開頭的URI與「http://www.yourapp.com/droid

<activity 
    android:name="com.yourapp.activity" 
    android:label="@string/title" > 
    <intent-filter android:label="@string/filter_title"> 
     <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="www.yourapp.com" 
       android:pathPrefix="/droid" /> 
     <!-- note that the leading "/" is required for pathPrefix--> 
     <!-- Accepts URIs that begin with "yourapp://droid」 --> 
     <data android:scheme="yourapp" 
       android:host="droid" /> 
    </intent-filter> 
</activity> 
+0

你能不能給我一個鏈接或這方面的任何示例代碼。其實https://codelabs.developers.google.com/codelabs/ Android的深層鏈接/ index.html的?指數= ..%2F%..#2Findex 0不能在工作室運行, –

+0

爲此,你必須google搜索關於「深層鏈接」,而且,這裏一個例子可能你你的問題的解決方案。https://github.com/airbnb/DeepLinkDispatch – TejaDroid

相關問題