16

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

enter image description here

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

3 Answers 3

17

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

enter image description here

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

3
  • Can you please give me some sample link how to use FBSDKSharePhoto. I am not finding facebook doc is so much helpful for multiple photo sharing Aug 5, 2015 at 18:19
  • @Dheeraj FBSDKSharePhotoContent, why with this its not possible. I want to post photo from image picker. They why should I use FBSDKShareLinkContent. Is there anyway to use FBSDKSharePhotoContent. Thanks a lot in advance Sep 13, 2016 at 7:57
  • actually, FBSDKShareDialog supports FBSDKSharePhotoContent also : - /
    – 0xxxD
    Mar 21, 2017 at 14:14
2

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.

1
  • 3
    As of facebook ios sdk 4.10.0, there is still no fallback if there is no native Facebook app installed.
    – chubao
    Feb 23, 2016 at 2:30
0

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];
1
  • 1
    getting Error Domain=com.facebook.sdk.share Code=2 "The operation couldn’t be completed. (com.facebook.sdk.share error 2.)" UserInfo=0x7faf8e99c8c0 {com.facebook.sdk:FBSDKErrorArgumentValueKey=<FBSDKSharePhotoContent: 0x7faf8dfe7ab0>, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Feed share dialogs support FBSDKShareLinkContent., com.facebook.sdk:FBSDKErrorArgumentNameKey=shareContent} Aug 5, 2015 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.