我正在使用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 (我不想要的东西)
案例B:在iPhone设置中注销Facebook (我想要的)
我还想指出,案例A和案例B的弹出行为也是不同的。案例A通过模仿SLComposeViewController的弹出窗口打开facebook分享,而案例B在浏览器上打开facebook分享。
我希望案例B发生的原因是,它通过"APP“而不是"iOS”显示共享,并且它能够正确地共享图像。有没有办法使情况B:即使用户登录到iPhone设置也会发生?或者更好的是,即使用户在设置中登录,仍然继续使用案例B?
顺便说一下,如果有帮助的话,我正在使用XCode 6.3和Swift。
谢谢。
发布于 2015-04-16 17:46:07
原来这个问题是由于FBSDKShareDialog引起的,使用FBSDKShareButton将始终使用FacebookSDK的共享功能。
为了做到这一点,我做了一个变通方法,以编程方式手动触发FBSDKShareButton,而不是创建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)https://stackoverflow.com/questions/29655105
复制相似问题