在没有安装Facebook App的情况下,FBSDKShareDialog不会共享照片

时间:2015-04-01 12:26:55

标签: ios facebook facebook-ios-sdk facebook-sdk-4.0

我正在使用Facebook SDK 4.0,https://developers.facebook.com/docs/sharing/ios#share_dialog 我使用FBSDKShareDialog分享Photo.It分享Photo如果用户安装了Facebook应用程序, 但是当用户没有安装FB App时它会失败。但他们说"如果某人没有安装Facebook应用程序,它将自动回退到基于网络的对话框。" Idk什么错了请帮我用FBSDK 4.0分享照片。

我的代码是

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.capturedImageView.image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
[FBSDKShareDialog showFromViewController:self
                             withContent:content
                                delegate:self];

这是错误报告

enter image description here

  

误差:" com.facebook.sdk:FBSDKErrorArgumentNameKey = shareContent,   com.facebook.sdk:FBSDKErrorDeveloperMessageKey = Feed共享对话框   支持FBSDKShareLinkContent。"

2 个答案:

答案 0 :(得分:16)

FBSDKShareDialog仅支持FBSDKShareLinkContent发布图片或URL。因此,要使用共享对话框,您必须使用FBSDKShareLinkContent。

enter image description here

您可以按如下方式使用它:

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.imageURL = [NSURL URLWithString:@"http://upload.wikimedia.org/wikipedia/commons/3/36/Hopetoun_falls.jpg"];
    [FBSDKShareDialog showFromViewController:self
                                 withContent:content
                                    delegate:self];

如果您想分享链接,请使用content.contentURL

请参阅:https://developers.facebook.com/docs/sharing/ios#share_dialog

如果您使用的是FBSDKSharePhoto,则需要安装原生Facebook for iOS应用程序。

请参阅:https://developers.facebook.com/docs/sharing/ios#photos

答案 1 :(得分:-1)

首先配置iOS设备的Facebook帐户,然后使用以下代码:

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];

photo.image = self.capturedImageView.image;

photo.userGenerated = YES;

FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];

content.photos = @[photo];

[FBSDKShareDialog showFromViewController:self
                             withContent:content
                                delegate:self];