【问题标题】:Photopicker & FB GrapSharer issues in iOS 11iOS 11 中的 Photopicker 和 FB GrapSharer 问题
【发布时间】:2018-03-15 16:45:21
【问题描述】:

我的代码在 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 一切都停止工作。任何帮助将不胜感激。

【问题讨论】:

    标签: ios swift facebook


    【解决方案1】:

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

    PHPhotoLibrary.requestAuthorization({ (status: PHAuthorizationStatus) -> Void in
                ()
    
                if PHPhotoLibrary.authorizationStatus() == PHAuthorizationStatus.authorized {
                    print("creating 2")
                    // Impelement UiImagepicker method
                }
    
            })
    

    【讨论】:

    • 没有为我解决问题。不知何故。我现在真的没办法了
    • 哪一个是你的问题?我希望您在 .plist 中添加这些密钥以访问相册中的任何内容:隐私 - 照片库使用说明和隐私 - 照片库添加使用说明。他们都。 @alexdd55
    • @SharadChauhan 嗨,对不起,我可以问一些相关的问题。我遇到了类似的问题,您的解决方案有所帮助,非常感谢!但现在我收到Access token is missing publish_actions permissions 错误。正如我看到的,你可能也有它,因为我看到你用if检查它。您能否分享一下您是如何获得该许可的?我试过这样做:loginManager.logIn(withPublishPermissions: "publish_actions", from: self)。但它打开 FB webview 并显示错误:Invalid Scopes: publish_actions... 参考:developers.facebook.com/docs/facebook-login/permissions
    • @TungFam 您在 .plist 中添加了 LSApplicationQueriesSchemes ?
    • @SharadChauhan 非常感谢您回复我:) 我解决了我的问题:) 非常感谢。如果您有兴趣,我在这里回答:stackoverflow.com/questions/47147616/…
    猜你喜欢
    • 1970-01-01
    • 2018-03-06
    • 2020-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多