Photopicker& iOS 11中的FB GrapSharer问题

时间:2017-10-04 10:14:02

标签: ios swift facebook

我的代码在iOS 10上运行良好,但在更新到iOS 11后似乎没有任何效果。

这是我在Facebook上分享视频的代码:

internal func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]){
        self.dismiss(animated: true, completion: { () -> Void in

        })
        guard let videoURL = info[UIImagePickerControllerReferenceURL] as? NSURL else {
            return // No video selected.
        }
        print(videoURL)
        let video = Video(url: videoURL as URL)
        var content = VideoShareContent(video: video)
        content.hashtag = Hashtag.init("#Ojas")

        if FBSDKAccessToken.current() != nil{
            if FBSDKAccessToken.current().hasGranted("publish_actions") {
                print("Have permission")
                let sharer = GraphSharer(content: content)
                sharer.failsOnInvalidData = true
                sharer.message = "From #Ojas App"
                sharer.completion = { result in
                    // Handle share results
                    print("Share results : \(result)")
                }

                do{
                    try sharer.share()
                    //try shareDialog.show()
                }catch{
                    print("Facebook share error")
                }

        }

    }

但是之前没有任何工作。 这是我在ImagePicker中看到的日志:

[discovery] errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}

现在有一个警告说"app_name" wants to use "facebook.com" to Sign in。 我提到的链接: PhotoPicker discovery error: Error Domain=PlugInKit Code=13

任何想法为什么一切都停止在iOS 11工作。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

好的,这是关于询问我在应用开始时已经问过的权限。我还需要再问一次,我不知道为什么,但它确实有效。

PHPhotoLibrary.requestAuthorization({ (status: PHAuthorizationStatus) -> Void in
            ()

            if PHPhotoLibrary.authorizationStatus() == PHAuthorizationStatus.authorized {
                print("creating 2")
                // Impelement UiImagepicker method
            }

        })