微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iOS 11中的Photopicker和FB GrapSharer问题

我的代码在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”想用“facebook.com”登录.
我提到的链接
PhotoPicker discovery error: Error Domain=PlugInKit Code=13

知道为什么一切都停止在iOS 11工作.任何帮助将不胜感激.

解决方法

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

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

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

        })

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐