Reputation: 1406
I'm trying to implement Universal Links in a Swift MacOS app, and clicking the link does open the app, but it's supposed to run the application function in AppDelegate with this signature:
func application(_ application: NSApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([NSUserActivityRestoring]) -> Void) -> Bool
according to the documentation, but it isn't running. I've verified this using os_log()
- I've placed logs all around my app, including this function, and all are hit as expected except this one.
Here's the process of how I got to this point:
I need to have information from the link, so I really need to get the URL from userActivity
, but so far clicking the Universal Link seems to behave as if just clicked the app.
Am I missing something? Am I incorrectly expecting it to work similarly to iOS Universal Links?
Upvotes: 0
Views: 611
Reputation: 1406
It seems I have found the answer - in the docs (and even when you select "Jump to Definition" for NSApplicationDelegate), it says to use
restorationHandler: @escaping ([NSUserActivityRestoring]) -> Void
as your last parameter, but when you type "application" and select from the autocomplete, it comes up with
restorationHandler: @escaping ([Any]) -> Void
as the last parameter. With that in place instead, it was called when I clicked the Universal Link.
Upvotes: 1