Post

Replies

Boosts

Views

Activity

SwiftUI apps in macOS are not triggering onOpenURL when receiving a Universal Link
Hi I have a simple SwiftUI app with an onOpenURL handler to handle Universal Links, and my target is macOS: var body: some Scene { WindowGroup { ContentView() .environment(\.managedObjectContext, persistenceController.container.viewContext) .onOpenURL { url in print("Inside onOpenURL....") } } } I have also configured the Associated Domains capability, and the apple-app-site-association file in my domain, so when opening the link to that domain, my app is opened instead of Safari. So, when debugging the app, and clicking a Universal Link (for example, in Notes app), to open my app (which it does), I expect to see the "Inside onOpenURL...." message in the output window in Xcode, meaning the onOpenURL handler is handling the universal link. But this does not happen. Every time I click the universal link, the app is opened but nothing is displayed in Xcode. This is in macOS Big Sur 11.1, and also 11.2 with a recent update. However, if the same code is used to target an iOS 14 app, this works correctly, without changing any code, just the target of the app. Trying many things, I also discovered that if I used a custom URL scheme (myapp:// for example), the onOpenURL handler is called, in my macOS app. I can see the "Inside onOpenURL...." message. But this does not happen with universal links, and my app is targeted to macOS and universal links are required. Does anyone found this issue, and how to solve it? Thanks
2
0
1.3k
Feb ’21