简体   繁体   中英

FBSDKShareDialog doesn't share Photo without Facebook App installed, IOS

I am using Facebook SDK 4.0, https://developers.facebook.com/docs/sharing/ios#share_dialog I am using FBSDKShareDialog to share Photo.It does share Photo if user has installed Facebook app, But it fails when user hasn't installed FB App. but they say "If someone doesn't have Facebook app installed it will automatically falls back to a web-based dialog." Idk whats wrong please help me in sharing photo using FBSDK 4.0.

My code is

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];

This is error report

在此输入图像描述

error:"com.facebook.sdk:FBSDKErrorArgumentNameKey=shareContent, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Feed share dialogs support FBSDKShareLinkContent."

FBSDKShareDialog only supports FBSDKShareLinkContent to post image or URL.So to use share Dialog you have to use FBSDKShareLinkContent.

在此输入图像描述

You could use it as follows :

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];

If you want to share a link then just use content.contentURL .

Refer to : https://developers.facebook.com/docs/sharing/ios#share_dialog

If you are using FBSDKSharePhoto then you need the native Facebook for iOS app installed.

Refer to : https://developers.facebook.com/docs/sharing/ios#photos

I also had the same issue as the documentation is also saying that they provide fallback mechanisms, which seems not true for this case:

Built-In Share Fallbacks

In past versions of the SDK for iOS, your app had to check for a native, installed Facebook app before it could open the Share Dialog. If the person didn't have the app installed, you had to provide your own code to call a fallback dialog.

Now the SDK automatically checks for the native Facebook app. If it isn't installed, the SDK switches people to their default browser and opens the Feed Dialog. If someone wants to share an Open Graph story, the SDK opens the Web Share Dialog.

First configure Facebook account of iOS device before and then use following code it will work:

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM