Facebook分享内容只在iOS 9中分享网址 [英] Facebook share content only shares URL in iOS 9

查看:448
本文介绍了Facebook分享内容只在iOS 9中分享网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

分享 FBSDKShareLinkContent FBSDKShareDialog 在iOS 8中正常工作,但无法共享 imageURL contentTitle contentDescription 在iOS 9设备上。



该应用程序使用iOS 9 SDK,Xcode 7,Facebook SDK 4.7.0构建,



当出现对话框时,当FB应用程序安装在iOS 9设备上时,会出现错误,当通过将相应的URL添加到Info.plist来解决时,它不会解决问题。它只是日志语句不再出现了。

  -canOpenURL:URL失败:fbapi20150629:/ - 错误:此应用程序不允许查询方案fbapi20150629

这将导致一个空的帖子:



在iOS 8上,对话框是通过FB应用程序或者在没有安装FB应用程序时打开应用程序中的Safari vc。



为了比较起见,相同的代码可以从iOS 8设备工作:





更新:



虽然 @ rednuht的回答如下解决最初的问题,值得注意的是由@ sophie-fader指出的AppStore URL特定案例

解决方案

我有同样的问题,我使用的解决方法是将共享对话框模式设置为使用本机应用程序。 >

我正在使用Obj-C,但在Swift中应该是一样的:

  FBSDKShareDialog * dialog = [[FBSDKShareDialog alloc] init]; 
dialog.fromViewController = viewController;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeNative; //如果你没有在CanShow调用之前设置,canShow总是返回YES
if(![dialog canShow]){
//当没有FB应用程序
对话框时,回退演示.mode = FBSDKShareDialogModeFeedBrowser;
}
[dialog show];

在iOS 9中,用户获取了应用切换对话框,但它工作正常。还有 FBSDKShareDialogModeWeb ,它没有应用程序切换对话框,但也不显示图像。



默认值为 FBSDKShareDialogModeAutomatic ,它们选择 FBSDKShareDialogModeShareSheet ,这是您看到的。 >

更新:这是iOS9中可用对话框模式的行为:




  • FBSDKShareDialogModeAutomatic :使用ShareSheet,这是OP案例

  • FBSDKShareDialogModeShareSheet :ditto

  • FBSDKShareDialogModeNative :如果用户安装了FB应用程序,则会工作,否则无效。提交app-switch对话框。

  • FBSDKShareDialogModeBrowser :无图像的共享

  • FBSDKShareDialogModeWeb :无图像的共享

  • FBSDKShareDialogModeFeedBrowser 正常工作

  • FBSDKShareDialogModeFeedWeb 正常工作



浏览器打开Safari全屏,Web打开一个Webview对话框。



我会去最后一个iOS9的两个选项和iOS8的Automatic。


Share FBSDKShareLinkContent with FBSDKShareDialog works fine in iOS 8 but fails to share imageURL, contentTitle, contentDescription on iOS 9 devices.

The app is built with iOS 9 SDK, Xcode 7, Facebook SDK 4.7.0, all actions mentioned in Preparing Your Apps for iOS9 are done. The app is currently not available in App Store and Facebook app is in dev mode.

The code to present the dialog is pretty common (Swift 2.0):

let content = FBSDKShareLinkContent()

content.contentURL = <URL to the app in the App Store>
content.imageURL = <valid image URL>
content.contentTitle = <some title>
content.contentDescription = <some descr>

let shareDialog = FBSDKShareDialog()
shareDialog.fromViewController = viewController
shareDialog.shareContent = content
shareDialog.delegate = self

if !shareDialog.canShow() {
    print("cannot show native share dialog")
}

shareDialog.show()

On iOS 9 Facebook SDK presents native dialog with no image, title and description:

At the time the dialog is presented, when the FB app is installed on iOS 9 device, there is an error, which when resolved by adding respective URL to Info.plist does not fix the issue. It is just the log statement that does not appear anymore.

-canOpenURL: failed for URL: "fbapi20150629:/" - error: "This app is not allowed to query for scheme fbapi20150629"

This results in an empty post:

On iOS 8, though, the dialog is presented via FB app OR opens in-app Safari vc when FB app is not installed.

For the comparison sake, the same code works from iOS 8 devices:

UPDATE:

While @rednuht's answer below solves the initial issue, it worth noting about AppStore URL-specific case pointed out by @sophie-fader

解决方案

I was having the same issue, and the workaround I'm using is to set the Share Dialog mode to use the native app.

I'm using Obj-C, but should be pretty much the same in Swift:

FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = viewController;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeNative; // if you don't set this before canShow call, canShow would always return YES
if (![dialog canShow]) {
    // fallback presentation when there is no FB app
    dialog.mode = FBSDKShareDialogModeFeedBrowser;
}
[dialog show];

In iOS 9 the user gets the app-switching dialog, but it works fine. There's also FBSDKShareDialogModeWeb, which doesn't have the app-switching dialog, but it doesn't show the image, either.

The default is FBSDKShareDialogModeAutomatic, which chooses FBSDKShareDialogModeShareSheet, which is what you're seeing.

UPDATE: This is the behavior in iOS9 for the available dialog modes:

  • FBSDKShareDialogModeAutomatic: uses ShareSheet, which is the OP case
  • FBSDKShareDialogModeShareSheet: ditto
  • FBSDKShareDialogModeNative: works if the user has the FB app installed, fails silently otherwise. Presents app-switch dialog.
  • FBSDKShareDialogModeBrowser: shares without image
  • FBSDKShareDialogModeWeb: shares without image
  • FBSDKShareDialogModeFeedBrowser: works as intended
  • FBSDKShareDialogModeFeedWeb: works as intended

"Browser" open Safari full-screen, "Web" opens a webview dialog.

I'd go with either of the last two options for iOS9 and Automatic for iOS8.

这篇关于Facebook分享内容只在iOS 9中分享网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆