How to register method channel listener in native side
Hi, I want to call the method channel on iOS side in the background job, but I got the following error when I tried to do so:
flutter: Exception happen: MissingPluginException(No implementation found for method echo on channel com.foo.bar)
Declaring the method channel in AppDelegate.swift:
//=======================================================================================
//==================== iOS native side custom method channel callee ===================
//=======================================================================================
print("setup channel")
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let channel = FlutterMethodChannel(name: "com.foo.bar", binaryMessenger: controller.binaryMessenger)
channel.setMethodCallHandler({
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
if (call.method == "echo") {
result(call.arguments as? String);
} else {
result("Not Implemented")
}
})
Calling method channel from callbackDispatcher with:
final channel = MethodChannel("com.foo.bar");
await channel.invokeMethod<String>("echo", "${DateTime.now()}");
Any suggestions on this situation?
Hi, I want to call the method channel on iOS side in the background job, but I got the following error when I tried to do so:
flutter: Exception happen: MissingPluginException(No implementation found for method echo on channel com.foo.bar)Declaring the method channel in
AppDelegate.swift://======================================================================================= //==================== iOS native side custom method channel callee =================== //======================================================================================= print("setup channel") let controller : FlutterViewController = window?.rootViewController as! FlutterViewController let channel = FlutterMethodChannel(name: "com.foo.bar", binaryMessenger: controller.binaryMessenger) channel.setMethodCallHandler({ (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in if (call.method == "echo") { result(call.arguments as? String); } else { result("Not Implemented") } })Calling method channel from
callbackDispatcherwith:final channel = MethodChannel("com.foo.bar"); await channel.invokeMethod<String>("echo", "${DateTime.now()}");Any suggestions on this situation?
Did you solve the problem?
@heedongrichrich not yet.
Same issue facing here @LangInteger @heedongrichrich
@Nitingadhiya Man, I just decided to implement by myself hahaha~ It's a bit way better to implement background dispatch since there is no "one size fits all strategies" at this moment.
any update?