4

My code was working fine on iOS 10 but after updating to iOS 11 nothing seems to work.

This is my code For sharing video 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 is working as it was working before. Here is log I see for ImagePicker :

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

And now there is a alert saying "app_name" wants to use "facebook.com" to Sign in. Links I reffered : PhotoPicker discovery error: Error Domain=PlugInKit Code=13

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

Sharad Chauhan
  • 4,821
  • 2
  • 25
  • 50

1 Answers1

1

Okay, this is about asking permissions which I already asked at the beginning of my app. Still I need to ask again, I dont know why, but it worked.

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

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

        })
Sharad Chauhan
  • 4,821
  • 2
  • 25
  • 50
  • did not do the trick for me. somehow. i am really running out of options now – alexdd55 Nov 12 '17 at 19:23
  • which one is the issue for you ? and I hope you are adding these keys in .plist for accessing anything from album : Privacy - Photo Library Usage Description and Privacy - Photo Library Additions Usage Description. Both of them. @alexdd55 – Sharad Chauhan Nov 13 '17 at 07:48
  • @SharadChauhan hi, sorry may I ask somehow related question. I faced the similar issue and your solution helped, thanks a lot! But now I'm getting `Access token is missing publish_actions permissions` error. And as I see you probably had it too since I see you check it with the `if`. Could you please share how do you get that permission? I tried doing it this way: `loginManager.logIn(withPublishPermissions: "publish_actions", from: self)`. But it opens FB webview and it shows the error: Invalid Scopes: publish_actions... refer to: https://developers.facebook.com/docs/facebook-login/permissions – Tung Fam May 19 '18 at 22:57
  • @TungFam You added LSApplicationQueriesSchemes in your .plist ? – Sharad Chauhan May 21 '18 at 06:05
  • @SharadChauhan thanks a lot for getting back to me:) I solved my issue:) thanks a lot. if you are interested i answered it here: https://stackoverflow.com/questions/47147616/ios-facebookshare-error-reserved-being-returned/50433752#50433752 – Tung Fam May 21 '18 at 19:07