登录iPhone的Facebook设置会覆盖FacebookSDK共享



我正在使用FacebookSDK在我的应用程序上共享内容!不过,当用户在设置中登录iPhone的Facebook帐户时,我遇到了一些问题。这样做似乎覆盖了FacebookSDK的共享功能,这不是我想要的。

在这两种情况下,我都使用以下行在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)

案例A:在iPhone设置上登录Facebook(我不想要什么)

iPhone登录共享后

案例B:在iPhone设置上从Facebook注销(我想要什么)

Facebook SDK共享

我还想指出,案例A和B的弹出行为也不同。案例A通过模仿SLComposeViewController的弹出窗口打开facebook共享,而案例B在浏览器上打开facebook共享。

我希望案例B发生,因为它通过"APP"而不是"iOS"显示共享,并且它能够正确共享图像。即使用户登录了iPhone设置,是否有任何方法可以使情况B:发生?或者更好的是,即使用户在设置中登录,仍然继续处理情况B?

顺便说一句,如果有帮助的话,我会使用XCode 6.3和Swift。

谢谢。

原来问题是由FBSDKShareDialog引起的,使用FBSDKSshareButton将始终继续使用FacebookSDK的共享功能。

为了做到这一点,我做了一个变通方法,以编程方式手动触发FBSDKShareButton,而不是制作FBSDKSshareDialog。

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)

最新更新