共享对话框打开 Facebook 应用程序,尽管内容已成功共享,但我总是收到 .cancelled 回调。在这两种情况下 - 当我取消共享时和共享成功时。知道出了什么问题吗? Pod 版本:
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)")
}
}
配置
<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 Controller 显示 FB 共享对话框:
{
let shareDialog: FBSDKShareDialog = FBSDKShareDialog()
shareDialog.shareContent = content
shareDialog.delegate = self
shareDialog.fromViewController = self
shareDialog.show()
}
这可以让我分享 Facebook 的链接。您可以使用委托(delegate)方法来获取共享状态回调。
关于ios - Facebook ShareDialog 在完成时始终返回 .canceled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43064013/