Reputation: 2708
I would like to enable users in my app to share certain content on their facebook page such as: url, photo, text.
This is the only piece of documentation that I could find on facebook website. I can't find any proper tutorial.
Do I need to add any method in App Delegate to configure facebook sdk?
What is the type of myContent
?
I don't know where to start.
import FacebookShare
let shareDialog = ShareDialog(content: myContent)
shareDialog.mode = .Native
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in // Handle share results }
try shareDialog.show()
pods spec
Installing Bolts (1.9.0)
Installing FBSDKCoreKit (4.38.0)
Installing FBSDKLoginKit (4.38.0)
Installing FBSDKShareKit (4.38.0)
Installing FacebookCore (0.5.0)
Installing FacebookLogin (0.5.0)
Installing FacebookShare (0.5.0)
Upvotes: 0
Views: 1913
Reputation: 1292
There is a difference between Message Dialog
and Share Dialog
, the message dialog opens the messenger app with the content, and the share dialog opens the share option in the facebook app, from your code it looks like you are trying to open the share option so you should edit the question title, secondly myContent
is a type of object that conforms to the ContentProtocol
, for example like you said sharing a url, you need to create a LinkShareContent
, here is an example:
let linkContent = LinkShareContent(url: URL(string: "https://www.google.com/")!, quote: nil)
let shareDialog = ShareDialog(content: linkContent)
shareDialog.completion = { result in
// Handle share results
}
do {
try shareDialog.show()
} catch {
print(error)
}
note: for a photo you can create a PhotoShareContent
.
Upvotes: 1