Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Facebook ShareDialog始终返回。完成时取消_Ios_Swift_Facebook - Fatal编程技术网

Ios Facebook ShareDialog始终返回。完成时取消

Ios Facebook ShareDialog始终返回。完成时取消,ios,swift,facebook,Ios,Swift,Facebook,“共享”对话框打开facebook应用程序,尽管内容已成功共享,但我始终收到。已取消回调。在这两种情况下-当我取消共享和共享成功时。你知道怎么了吗? Pods版本: 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

“共享”对话框打开facebook应用程序,尽管内容已成功共享,但我始终收到。已取消回调。在这两种情况下-当我取消共享和共享成功时。你知道怎么了吗? Pods版本:

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>
LSApplicationQueriesSchemes
fbapi
fb messenger api
fbauth2
fbshareextension
CbundleurlTypes
循环流化床锅炉方案
fb188***33776
FacebookAppID
18851***3776
FacebookDisplayName
8MWC

使用以下代码向当前视图控制器显示FB共享对话框:

{
   let shareDialog: FBSDKShareDialog = FBSDKShareDialog()
    shareDialog.shareContent = content
    shareDialog.delegate = self
    shareDialog.fromViewController = self
    shareDialog.show()
}

这对我分享facebook的链接很有用。您可以使用委派方法获取共享状态回调

首先,检查是否为
发布操作授予了权限,如果是,则
共享
您的
内容
。 否则,请从用户处获得在其时间轴上发布帖子的权限,然后在授予权限的情况下共享帖子

   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!)")
            }
        })
    }

您向用户请求发布权限了吗?没有。在文档和共享工作中没有这方面的内容,但回调除外。这是针对旧sdk的。新的apishareDialog.presentingViewController=self具有不同的apishareDialog。谢谢你,现在公布行动。