flutter_background_service
flutter_background_service copied to clipboard
Cannot invoke service from notification action callback
I've added a STOP action button for the foreground service notification and I receive the tap but the service does not receive the stopService message. Is this an issue or am I missing something?
@pragma('vm:entry-point')
static void notificationTapBackground(
NotificationResponse notificationResponse) {
_debugPrint('notification tapped in background: $notificationResponse');
DartPluginRegistrant.ensureInitialized();
if (notificationResponse.actionId == stopServiceActionId) {
_debugPrint('Tapped action id ${notificationResponse.actionId}');
FlutterBackgroundService().invoke('stopService');
}
}
@pragma('vm:entry-point')
void onStartAndroidForegroundService(ServiceInstance service) async {
_debugPrint('On start foreground service callback');
DartPluginRegistrant.ensureInitialized();
service.on('stopService').listen((_) {
_debugPrint('Stopping foreground service ...');
service.stopSelf();
});
}
I also facing this issue? Any one find solutions?
When I invoke from UI it's proper working, but not invoke from notification action button
When I invoke from UI it's proper working, but not invoke from notification action button
@ohari5336 Did you find any solution to this to invoke service from notification?
i have facing the same issue but scenario is different. I have to pause and stop the timer as notification action, when user click on the action button of notification, action is detected but when i tried to pass that notification response another side with getx then always getting response as getx controller is again registered but it is already registered and when i tried to stop and pause from ui then it is working fine. @johnray016 @ohari5336 , did you guys find any solution for this type of issue ?