-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protocol Handler not working with flutter version 3.16.0 in Macos #12
Comments
I'm seeing the same issue. It works fine in iOS. |
Moving the listener to AppDelegate worked for me for now on https://github.com/knoeone/soundsetr/blob/main/macos/Runner/AppDelegate.swift#L14 override func applicationWillFinishLaunching(_ notification: Notification) {
super.applicationWillFinishLaunching(notification)
NSAppleEventManager.shared().setEventHandler(self, andSelector:#selector(handleURLEvent(_:with:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
}
@objc public func handleURLEvent(_ event: NSAppleEventDescriptor, with replyEvent: NSAppleEventDescriptor) {
guard let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue else { return }
let window = self.mainFlutterWindow?.contentViewController as! MacOSWindowUtilsViewController
let messenger = window.flutterViewController.engine.binaryMessenger
let channel = FlutterMethodChannel(name: "protocol_handler", binaryMessenger: messenger)
let args: NSDictionary = [
"url": urlString,
]
channel.invokeMethod("onProtocolUrlReceived", arguments: args)
} |
its working but its not the best solution we need to fix this in plugin side |
Thanks, @spacedevin! Also, if you are not using the @objc public func handleURLEvent(_ event: NSAppleEventDescriptor, with replyEvent: NSAppleEventDescriptor) {
guard let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue else { return }
//These two lines are different
guard let window = NSApplication.shared.windows.first else{ return }
let controller = window.contentViewController as! FlutterViewController
let messenger = controller.engine.binaryMessenger
let channel = FlutterMethodChannel(name: "protocol_handler", binaryMessenger: messenger)
let args: NSDictionary = [
"url": urlString,
]
channel.invokeMethod("onProtocolUrlReceived", arguments: args)
} |
the protocol listeners did'nt work even thought the cusotm uri permission is added in info.plist file
The text was updated successfully, but these errors were encountered: