Facebook ShareDialog总是返回,完成时取消
共享对话框打开Facebook应用程序,尽pipe内容共享成功,我总是收到.cancelledcallback。 在这两种情况下 – 当我取消共享,当共享成功。 任何想法是什么错误? 豆荚版本:
Using Bolts (1.8.4) Using FBSDKCoreKit (4.20.2) Using FBSDKLoginKit (4.20.2) Using FBSDKShareKit (4.20.2) Using FacebookCore (0.2.0) Using FacebookLogin (0.2.0) Using FacebookShare (0.2.0)
显示对话框的代码片段:
@IBAction func onShareClicked(_ sender: UIButton) { do{ var myContent = LinkShareContent(url: URL(string: "https://www.facebook.com/8MinuteWorkoutChallenge")!) myContent.hashtag = Hashtag("#8MWC") let shareDialog = ShareDialog(content: myContent) shareDialog.mode = .native shareDialog.failsOnInvalidData = true shareDialog.completion = { result in switch result { case .success: print("Share succeeded") case .failed: self.shareButton.isHidden = true case .cancelled: print("Share cancelled") } } try shareDialog.show() } catch { print("Error: \(error)") } }
configuration
<key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array> <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>fb188***33776</string> </array> </dict> </array> <key>FacebookAppID</key> <string>18851***3776</string> <key>FacebookDisplayName</key> <string>8MWC</string>
使用下面的代码来显示当前View控制器的FB共享对话框:
{ let shareDialog: FBSDKShareDialog = FBSDKShareDialog() shareDialog.shareContent = content shareDialog.delegate = self shareDialog.fromViewController = self shareDialog.show() }
这适用于我分享链接到Facebook。 您可以使用委托方法来获取共享状态callback。
首先,检查是否授予publish action
权限,如果是,则share
您的content
。 否则,获得用户的许可,在他们的时间表上发布post,然后在授予权限的情况下共享post。
if FBSDKAccessToken.current().hasGranted("publish_actions") { if FBSDKShareAPI().self.canShare() { FBSDKShareAPI.share(with: videoContent, delegate: self) } else { print("Graph API can not share your video") } } else { // Get publish_actions permission from fb app and upload photo to share. let loginManager = FBSDKLoginManager() loginManager.logIn(withPublishPermissions: ["publish_actions"], from: fromViewController, handler: { (result, error) in if result != nil && error == nil { if FBSDKShareAPI().self.canShare() { FBSDKShareAPI.share(with: videoContent, delegate: self) } else { print("Graph API can not share your video") } } else if error != nil { print("Error in sharing photo:- \(error!)") } }) }
- 如何在Phonegap / Cordova项目中实施Facebook移动安装广告跟踪?
- iPhone – 如何使用Facebook iOS SDK发送apprequests
- ios非对话Facebook分享失败,没有错误,没有反馈
- 如果Twitter或Facebook帐户没有在iOS 6上configuration,该怎么办?
- 断点2.1错误parsing/ Facebook的iOS SDK
- PFLogInViewController错误 – 用Parse注销后无法loginFacebook
- 如何从iOS中的Facebook SDK获取用户信息?
- Facebook对话框失败,错误:操作无法完成。 (NSURLErrorDomain错误-999。)
- Facebook iOS SDK 3.x提要对话框消失了吗?