Android的 - Facebook分享内容被覆盖被覆、内容、Android、Facebook

2023-09-05 01:54:27 作者:比钻石还耀眼的男人ヽ

这是我的code分享高分在Facebook上:

This is my code to share the high score on Facebook:

ShareLinkContent content = new ShareLinkContent.Builder()
  .setImageUrl(Uri.parse("https://m.xsw88.com/allimgs/daicuo/20230905/668.png"))
  .setContentTitle("I scored "+numPoints+" points!")
  .setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=com.my.package"))
  .setContentDescription("Get the game free on Google Play and beat my score.")        
  .build();
ShareDialog shareDialog = new ShareDialog(this);
shareDialog.show(content);

和这个伟大的工程,当URL是一些随机的网站(如developers.facebook.com),但是,当它有一个链接到谷歌播放的内容标题和内容描述被覆盖 - 标题被覆盖从Play商店称号与内容描述是空白的。

And this works great when the URL is some random site (like developers.facebook.com) but when it's a link to Google Play, the content title and content description get overwritten - title gets overwritten with the title from the Play store and content description is blank.

那么,怎样才能链接到应用程序上的Play商店,但保留了自定义标题和说明?我知道这是可能的,因为我见过的其他应用程序做到这一点:

So how can link to the app on the Play store but keep the custom title and description? I know it's possible because I've seen other apps do it:

推荐答案

您可以使用deeplinking的方法来实现这一目标。 所有你需要的是建立一个HTML页面,并把所有商店的链接(谷歌播放,应用程序商店)中的meta标签,并尝试共享该链接。您将能够达到你想要什么,也只有在用户打开Android上,他的应用程序/她将被重定向到谷歌播放,如果用户打开iOS​​上,他的应用程序/她将被重定向到App Store的页面。

You can use deeplinking method to achieve that. All you have to is create a html page and put all store links(Google Play, App Store) in that a meta tag and try to share that link. You would be able to achieve what you want and also if the user opens the app on Android he/she will be redirected to Google Play and if the user opens the app on iOS he/she will be redirected to App Store page.