Facebook: sharing a Play Store link using the Share Dialog

寵の児 提交于 2019-12-23 17:41:34

问题


I share a link using the share dialog from the Facebook Android SDK. My code looks like this:

FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
          .setName("My app name")
          .setCaption("A caption")
          .setDescription("My description...")
          .setLink("https://play.google.com/store/apps/details?id=com.company.myapp")
          .setPicture("http://link_to_picture")
          .build();

As I want users to be redirected to my app's Play Store page, I put this url in the link. But in that case, the post doesn't show the information I specified (name, caption, description). Instead, it shows the app name specified in the Play Store, with a "download it" caption (the picture is ok).

When I set another link, this issue doesn't occur: the post displays the name, caption and description as expected. Why can't I put my own text with a Play Store link?

EDIT

I tried using App Links. So I created an App Link object with this:

curl https://graph.facebook.com/app/app_link_hosts \
-F access_token="APP_ACCESS_TOKEN" \
-F name="My app link" \
-F android=' [
    {
      "url" : "myapp://share/1234",
      "package" : "com.company.myapp",
      "app_name" : "My app",
    },
 ]' \
-F web=' {
    "should_fallback" : false,
  }'

And I got this url: https://fb.me/494085890722766

Now, the post looks good, but clicking on it from Facebook app when my app is not installed pops up a chooser that proposes to open the link in a browser or install the application, which is not a good user experience.


回答1:


Finally, I found a workaround using App Links, which is detailed here : https://developers.facebook.com/docs/applinks/hosting-api

I created my App Link object without any "-F web" parameter, like this:

curl https://graph.facebook.com/app/app_link_hosts \
-F access_token="APP_ACCESS_TOKEN" \
-F name="My app link" \
-F android=' [
    {
      "url" : "myapp://share/1234",
      "package" : "com.company.myapp",
      "app_name" : "My app",
    },
 ]'

However, I don't understand why Facebook API works in a so weird way. It's a complicated solution to a simple issue.




回答2:


Replace your link with

 .setLink("market://details?id=com.company.myapp")

See this link




回答3:


In my case, I disable DeepLink in Facebook Developer Console and it work well.



来源:https://stackoverflow.com/questions/24262169/facebook-sharing-a-play-store-link-using-the-share-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!