Kevin Ke
Kevin Ke

Reputation: 11

Swift 3: Share Button of Facebook SDK is Disabled

The Share Button is Invalid/Disabled

Hey guys,

So I'm trying to use Facebook SDK on my personal app development, which used swift 3. However, when I tried to use the Share Button, it is always disabled in grey background color, and I have no idea what should I change after went over the Facebook SDK documents and references.

Does anyone know how to solve it? Here is how I write my share button:

let shareButton = ShareButton(frame: CGRect(x: 50.0, y: 25.0, width: 200, height: 40), content: (LinkShareContent(url: URL(string: "theURLAddress")!)))
view.addSubview(shareButton)

Upvotes: 1

Views: 762

Answers (1)

Mina
Mina

Reputation: 2222

Objective-C SDK:

Update your Facebook SDK to the latest one(v4.x), and use the following code:

let shareButton = FBSDKShareButton(frame: CGRect(x: 50.0, y: 25.0, width: 200, height: 40))
let content = FBSDKShareLinkContent()
content.contentURL = URL(string: "theURLAddress")
content.quote = "some quote "
shareButton.shareContent = content
self.view.addSubview(shareButton)

Swift SDK:

with swift SDK, use the following code with the real URL not a fake one.

let shareButton = ShareButton<LinkShareContent>()
let content = LinkShareContent(url: URL(string: "https://stackoverflow.com/a/45263496/1724845")!)
shareButton.content = content
shareButton.frame = CGRect(x: 50.0, y: 25.0, width: 200, height: 40)
view.addSubview(shareButton)

Upvotes: 1

Related Questions