Skip to content

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

@rijink7

Description

@rijink7

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)
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions