PhotoPixer and FB GrapSharer issues in iOS 11

My code worked fine on iOS 10, but after upgrading to iOS 11 nothing works.

This is my code. To share videos on 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")
                }

        }

    }

But nothing works as before. Here is the log I see for ImagePicker:

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

And now a warning appears "app_name" wants to use "facebook.com" to Sign in. Links I said: PhotoPicker detection error: Domain error = PlugInKit code = 13

Any idea why everything stopped working for iOS 11. Any help would be appreciated.

+4
source share
1 answer

Well, this is about asking for permissions, which I already requested at the beginning of my application. However, I need to ask again, I don’t know why, but it worked.

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

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

        })
0
source

Source: https://habr.com/ru/post/1686868/


All Articles