Open shriyaapptware opened 1 year ago
Hi @ekasetiawans I am using Android and IOS SDK's and background services also working at native side because of the SDK. I can find the logs at native side when my app is closed or in background. Now I have to fetch that data in my flutter code using method channel. Would it be possible to get that native data in flutter?
Has there been any upldate?
I am trying to call method channel that communicate with Android native when app is closed. onStart method is the one that provides logs in background and when app is closed. So I called methodchannel inside onStart method but it gives me exception MissingPluginException.
`
@pragma('vm:entry-point') void onStart(ServiceInstance service) async { if (service is AndroidServiceInstance) { service.on('setAsForeground').listen((event) { service.setAsForegroundService(); }); service.on('setAsBackground').listen((event) { service.setAsBackgroundService(); }); } service.on('stopService').listen((event) { service.stopSelf(); }); Timer.periodic(const Duration(seconds: 5), (timer) async { if (service is AndroidServiceInstance) { try { var returnData = await bgMethodChannel.invokeMethod(bgMethod); print("returnData --------- " + returnData); } catch (e) { if (kDebugMode) { print("EXCEPTION: $e"); } } } }); } `
Is there any way to call methodchannel from the onStart method?