MacOS - WidgetKit handle links from widget in containing app

Hello,

Trying to handle custom url links from widget in Mac. It opens containing app but not any method gets called to get URL and handle action.


Tried below way for handling custom url.
Code Block
NSAppleEventManager
                .shared()
                .setEventHandler(
                    self,
                    andSelector: #selector(handleURL(event:reply:)),
                    forEventClass: AEEventClass(kInternetEventClass),
                    andEventID: AEEventID(kAEGetURL)
                )


Above method in applicationDidFinishLaunching method, but that method not getting called.

Widget has code like,

Code Block
struct TestMacWidgetEntryView : View {
    var url = URL(fileURLWithPath: "testWid://test?abc=123")
    var entry: Provider.Entry
    var body: some View {
        Link(destination: url) {
            Text(entry.date, style: .time)
        }
    }
}


Anyone has idea how to get that url in containing app to perform action from widget links?


MacOS - WidgetKit handle links from widget in containing app
 
 
Q