Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL Schemes not working on macOS

I'm working on an app that needs to get an authorization token from an external provider. So, I need a custom URL scheme for the redirection callback.

The redirection callback is: chirper://success.

I registered the URL Scheme in my Info.plist: URL Scheme

I also added the following method in my AppDelegate.swift:

func handleGetURLEvent(event: NSAppleEventDescriptor?, replyEvent: NSAppleEventDescriptor?) {
    if let aeEventDescriptor = event?.paramDescriptor(forKeyword: AEKeyword(keyDirectObject)) {
        if let urlStr = aeEventDescriptor.stringValue {
            let url = URL(string: urlStr)
            print(url)
            // do something with the URL
        }
    }
}

But when I open the redirection callback URL with Safari, this is what I get: Safari

Safari can't open this URL because macOS doesn't recognize URLs that start with chirper:

like image 792
Arthur Guiot Avatar asked Mar 06 '23 22:03

Arthur Guiot


2 Answers

Try to "Clean Build Folder" and rebuild. Did help for me. Looks like this is required in some cases.

like image 68
toma Avatar answered Mar 09 '23 06:03

toma


According to the answer to this question, the problem is the inclusion of :// in the callback URL. If you remove those, the URL should be opened. I found this was correct on macOS 10.15.5.

like image 42
Belle B. Cooper Avatar answered Mar 09 '23 06:03

Belle B. Cooper