Reputation: 445
I am using FacebookSDK to share content on my app! I encountered some problems though when the user is logged in on their iPhone's Facebook account on settings. Doing so seems to override FacebookSDK's sharing functionality, which is not what I wanted to happen.
In both cases, I am using the following lines to share content on Facebook:
let content:FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "http://www.google.com")
content.contentTitle = "Link Title"
content.contentDescription = "Link Description"
content.imageURL = NSURL(string: "Image Link")
FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: nil)
Case A: Logged in on Facebook on iPhone Settings (What I don't want)
Case B: Logged out of Facebook on iPhone Settings (What I want)
Would also just like to point out that the popup behaviour is also different for Case A and B. Case A's opens facebook sharing via a popup that mimics that of SLComposeViewController, while Case B opens facebook sharing on a browser.
I wanted Case B to happen for reasons that it shows the share via "APP" and not via "iOS" and that it is able to properly share the image. Is there any way to make Case B: happen even if the user is logged on the iPhone settings? Or better yet still proceed with Case B even if user is logged on in the settings?
By the way, I'm using XCode 6.3 and Swift if that helps.
Thanks.
Upvotes: 1
Views: 534
Reputation: 445
Turned out the problem was arising due to FBSDKShareDialog, using FBSDKShareButton will ALWAYS proceed with FacebookSDK's sharing function.
In order to do this, I made a workaround to manually trigger the FBSDKShareButton programmatically instead of making a FBSDKShareDialog.
let content:FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "http://www.google.com")
content.contentTitle = "Link Title"
content.contentDescription = "Link Description"
content.imageURL = NSURL(string: "Image Link")
//FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: nil)
let button:FBSDKShareButton = FBSDKShareButton()
button.frame = CGRectMake(0, 0, 0, 0)
button.shareContent = content
button.sendActionsForControlEvents(UIControlEvents.TouchUpInside)
Upvotes: 2