I am trying to open a file from the Finder app with my Flutter app. However, the method that is expected to be called when opening a file is never being invoked.
I’ve created a custom file extension for my flutter app and already registered it in the Info.plist
for MacOS. Files of the custom type are already being recognized by the operating system and are displayed with the correct icon. Double clicking one of them opens or focuses my Flutter app.
I have read online that the correct way to listen to opened files on MacOS is to override the application(_ application: NSApplication, open urls: [URL])
method of FlutterAppDelegate
in AppDelegate.swift
. So far my code looks like this:
@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
...
override func application(_ application: NSApplication, open urls: [URL]) {
ApplicationService.shared?.methodChannel.invokeMethod("print", arguments: "Hello World!")
}
...
}
But as it seems, the method is never being called. It can’t be methodChannel, as it successfully sends a print, when initialized.
I even tried removing all pub libraries from my project in order to see if any of them have an impact on the problem. Is it still possible that there is a Flutter plugin that is consuming the "OpenUrl" Event?
Any help is appreciated! Thanks 🙂
2
Answers
The
application(_ application: NSApplication, open urls: [URL])
might not work due to:Info.plist
.urls
usingURLDecoder
.Debug with logging and inspect values to pinpoint the issue.
mÃa música
), again, start with some simple file in your home directory