4

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:

Arthur Guiot
  • 713
  • 10
  • 25

2 Answers2

6

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

toma
  • 1,471
  • 12
  • 20
1

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.

Belle B. Cooper
  • 375
  • 5
  • 13