Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rijink7 opened this issue Feb 3, 2021 · 0 comments
Open

Comments

@rijink7
Copy link

rijink7 commented Feb 3, 2021

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)
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant