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
:
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 can't open this URL because macOS doesn't recognize URLs that start with
chirper: