Good day, maybe someone can help me here. I have a SDK built into Flutter that I call via the ChannelMethod. There I enter a callback whose result I want to give back to flutter. The callback works but for some unknown reason the result function is not triggered.
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let testChannel = FlutterMethodChannel(name: "test",
binaryMessenger: controller.binaryMessenger)
testChannel.setMethodCallHandler({
[weak self] (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
// This method is invoked on the UI thread.
guard call.method == "startProcess" else {
result(FlutterMethodNotImplemented)
return
}
let args = call.arguments as! Dictionary<String, Any>
let mainVC = ViewController()
mainVC.callBack = { (resultValue: String) in
print("Callback called:")
print(resultValue)
// <-------- this does not work -------->
result(resultValue)
result("test")
};
mainVC.caseId = args["caseId"] as! String
let navigationController = UINavigationController(rootViewController: mainVC)
self?.window.rootViewController = navigationController
self?.window.makeKeyAndVisible()
})
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}