Facebook ShareDialog总是返回.canceled完成 [英] Facebook ShareDialog always returns .canceled on completion
本文介绍了Facebook ShareDialog总是返回.canceled完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Pods版本:
使用螺栓(1.8.4)
使用FBSDKCoreKit(4.20.2)
使用FBSDKLoginKit(4.20.2)
使用FBSDKShareKit(4.20.2)
使用FacebookCore(0.2.0)
使用FacebookLogin(0.2.0)
使用0.2.0)
显示对话框的片段:
@IBAction func onShareClicked(_ sender:UIButton){
do {
var myContent = LinkShareContent(url:URL(string:https:// www
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 {
打印(错误:\(错误))
}
}
config
< 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>
解决方案
使用下面的代码显示FB共享对话框当前视图控制器:
{
let shareDialog:FBSDKShareDialog = FBSDKShareDialog()
shareDialog.shareContent = content
shareDialog.delegate = self
shareDialog.fromViewController = self
shareDialog.show()
}
这适用于我分享到Facebook的链接。您可以使用委托方法来获取共享状态。
Share dialog opens facebook app and despite content is shared successfuly I always receive .cancelled callback. In both cases - when I cancel sharing and when sharing is successfull. Any idea what is wrong? Pods versions:
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)
Snippet for showing dialog:
@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)")
}
}
config
<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>
解决方案
Use this below code to show the FB share Dialog to current View controller:
{
let shareDialog: FBSDKShareDialog = FBSDKShareDialog()
shareDialog.shareContent = content
shareDialog.delegate = self
shareDialog.fromViewController = self
shareDialog.show()
}
This works for me to share the link to facebook. You can use delegation method to get the share status call back.
这篇关于Facebook ShareDialog总是返回.canceled完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文