cordova-spotify-oauth icon indicating copy to clipboard operation
cordova-spotify-oauth copied to clipboard

Ios - SpotifyOAuthPlugin.swift - observer not seems to be working

Open rijink7 opened this issue 4 years ago • 0 comments

the plugin works well up to auth process after auth the SFSafariViewController stays in the spotify redirect page does not dismiss the SFSafariViewController.

    var observer: NSObjectProtocol?
    observer = NotificationCenter.default.addObserver(
        forName: NSNotification.Name.CDVPluginHandleOpenURL,
        object: nil,
        queue: nil
    ) { note in
        let url = note.object as! URL
        guard url.absoluteString.contains("code") else { return }
        
        svc.presentingViewController!.dismiss(animated: true, completion: nil)
        NotificationCenter.default.removeObserver(observer!)
        self.currentNsObserver = nil
        self.currentCommand = nil

        let res = CDVPluginResult(
            status: CDVCommandStatus_OK,
            messageAs: [
                "code": url["code"]
            ]
        )
        self.commandDelegate.send(res, callbackId: command.callbackId)
    }

rijink7 avatar Feb 03 '21 12:02 rijink7