cordova-spotify-oauth
cordova-spotify-oauth copied to clipboard
Ios - SpotifyOAuthPlugin.swift - observer not seems to be working
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)
}