0
votes

Im using FBSDKShareKit (4.22.1), i'm trying to share photo with the following code:

let photo = FBSDKSharePhoto()
photo1.imageURL = URL(string: "sample url")
photo.isUserGenerated = false  
let photoContent = FBSDKSharePhotoContent()
photoContent.photos = [photo]
FBSDKShareDialog.show(from: self, with: photoContent, delegate: nil)

but it only works when the native Facebook app is installed on the phone. I also tried to show the content with Share Button instead of Share Dialog like:

var shareButton = FBSDKShareButton()
shareButton.shareContent = photoContent
shareButton.center = self.view.center
self.view.addSubview(shareButton)

it didn't work, if app was not installed either.

i want the FBSDK i used in my app, opens Safari when Facebook app is not installed, it opens safari by default for FBSDKShareLinkContent, but not working for FBSDKSharePhotoContent. does anyone know what is the problem?

2

2 Answers

2
votes

I have implemented another way to share photos using Graph API. It was very helpful. Here is a link. Just what you need is to take the permissions from the user to publish_actions before posting. Also there is no native facebook app installed. Just got logged in through Browser.

1
votes

Well, I found the answer in Facebook developer website, which is:

Photos

People can share photos from your app to Facebook with the Share Dialog or with a custom interface:

Photos must be less than 12MB in size

People need the native Facebook for iOS app installed, version 7.0 or higher

you can also ask for "publish_actions", you need to login twice, first with readPermission for email, then when user wants to share a post loginWithPublishPermission for "publish_actions". the point is that you have to add "publish_actions" first of all in your Facebook developer account.