Wednesday, July 17, 2024
HomeiOS DevelopmentCan the FlutterBinaryMessenger be used for IPC between Flutter and a non-UI...

Can the FlutterBinaryMessenger be used for IPC between Flutter and a non-UI MacOS/iOS app extension


I am creating a Flutter software and a non-UI (MacOS/iOS) File Supplier Extension. The extension runs in a separate course of and I would like the Flutter code to speak with the extension.

Ideally I’d have one BasicMessageChannel within the flutter app and one FlutterBinaryMessenger within the extension.

To date, I’ve managed to have the above lessons to speak however solely between the flutter isolate and the internet hosting app’s Swift code which accommodates the AppDelegate. The code is much like this.

Having the FlutterBinaryMessenger within the extension code is considerably tougher. I attempted this code:

let bundle = Bundle()
let challenge = FlutterDartProject(precompiledDartBundle: bundle)
let flutterEngine = FlutterEngine(title: "Extension flutter engine", challenge: challenge)
let flutterMessenger = flutterEngine.binaryMessenger;
let flutterMessenger.setMessageHandlerOnChannel(
    "my.app.instance/fileProvider",
    binaryMessageHandler: { message, reply in
        NSLog("Obtained message within the extension: (message as Optionally available)")
        reply(nil)
    }
)
let success = flutterEngine.run(withEntrypoint: nil)
NSLog("Success beginning flutter engine: success")

Sadly the flutterEngine.run(withEntrypoint: nil) command returns false and I am unsure the way to progress from there.

The opposite drawback is that even when I do get the engine to begin, I am not even certain whether or not Inter Course of Communication is meant to work with these Flutter message channels or whether or not it is simply to help communication with the Flutter isolate and its internet hosting code that each run in the identical course of.

I can consider a workaround, which might be to make use of Flutter Messenger for the communication between Flutter and the internet hosting app after which use XPC for communication between the internet hosting app and the extension. Although wish to keep away from that if attainable.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments