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."

Dharmesh Dhorajiya
  • 3,976
  • 9
  • 30
  • 39
Moaz Saeed
  • 1,006
  • 3
  • 10
  • 23

3 Answers3

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

Dheeraj Singh
  • 5,143
  • 25
  • 33
  • 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 – Shreesh Garg Aug 05 '15 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 – Rohit Wankhede Sep 13 '16 at 07:57
  • actually, FBSDKShareDialog supports FBSDKSharePhotoContent also : - / – 0xxxD Mar 21 '17 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.

ph1lb4
  • 1,982
  • 17
  • 24
  • 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 '16 at 02: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];
Dharmesh Dhorajiya
  • 3,976
  • 9
  • 30
  • 39
Vinod N
  • 148
  • 4
  • 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=, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Feed share dialogs support FBSDKShareLinkContent., com.facebook.sdk:FBSDKErrorArgumentNameKey=shareContent} – Shreesh Garg Aug 05 '15 at 18:19