Facebook 分享图片和 Applinks

Facebook Sharing with image and Applinks

我停留在 Facebook 分享上..

我想要的只是 post 来自我的 iOS 应用程序的图像,带有文本和应用程序link,可以将用户重定向到已安装的应用程序或 App Store。

App link 工作正常,我描述了一些像这样的元标记:

    <meta property="al:ios:url" content="cubeDev://" />
    <meta property="al:ios:app_store_id" content="1054030..." />
    <meta property="al:ios:app_name" content="My app name" />
    <meta property="al:web:should_fallback" content="false" />
    <meta property="og:image:width" content="50" />
    <meta property="og:image:height" content="50" />
    <meta property="og:image" content="https://spb.hh.ru/employer-logo/1625583.png" />
    <meta property="og:type" content="website" />
    <meta property="og:title" contetn="title" /> 
    <meta property="og:description" content="App description.." />
    <meta property="fb:app_id" content="31667067867..." />  

分享代码也很简单:

 FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
  content.contentURL = [NSURL URLWithString:@"http://176.31.132.151:8000/"];
  content.imageURL = [feedCell imageURL];
  content.quote = [feedCell text];

  FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
  shareDialog.mode = FBSDKShareDialogModeNative;
  if(!shareDialog.canShow) {
    shareDialog.mode = FBSDKShareDialogModeFeedBrowser;
  }
  shareDialog.fromViewController = self;
  shareDialog.shareContent = content;
  shareDialog.delegate = self;
  [shareDialog show]; 

其中 http://176.31.132.151:8000/ 是我的应用程序 link。

当您在应用程序 link 的元标记中描述图像时,图像 url 属性 似乎不起作用..

所以,我的目标是 post 来自应用程序的图像和文本,以及应用程序 link 下面的应用程序图标和说明..

如有任何帮助,我们将不胜感激。

参观后Facebook bugs page

我找到了一位 Facebook 团队成员对此行为的解释,似乎目前的 fb sdk 无法做到这一点, 唯一的解决办法是创建一个带有动态参数的应用 link 页面。没有我预期的那么好。

Roemer Vlasveld · · Facebook Team Hi Deepak,

...

It turns out that this behaviour is by design. In the past, the experience with sharing both a photo and a link caused a mixed experience. Currently, when sharing both a photo and a link, only the link will be used to create a preview.

The workaround would be to add the photo as an Open Graph image to the link that will be shared. This might require that each link is unique, but that will ensure that the preview created (at least in the created post) uses the image from the provided link.

I will mark this bug as 'By Design', since it reflects intended behavior. If you still encounter problems with this, feel free to reopen by leaving a new comment or reply.

Roemer