I am using flutter_local_notifications to create notifications with actions.
final _notificationDetailsWithActions = NotificationDetails(
android: AndroidNotificationDetails(
notificationChannel.id,
notificationChannel.name,
channelDescription: notificationChannel.description,
importance: notificationChannel.importance,
priority: Priority.high,
actions: <AndroidNotificationAction>[
const AndroidNotificationAction('id_exit', 'Exit',
cancelNotification: true),
],
),
iOS: const DarwinNotificationDetails(
presentAlert: true,
presentSound: true,
presentBadge: true,
sound: 'notification.wav',
),
);
then I have
await _flutterLocalNotifications.initialize(
settings,
onDidReceiveNotificationResponse:
(NotificationResponse notificationResponse) {
},
onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
);
and
@pragma('vm:entry-point')
void notificationTapBackground(NotificationResponse notificationResponse) {
// ignore: avoid_print
debugPrint(
'notification(${notificationResponse.id}) action tapped, actionId:
${notificationResponse.actionId}');
if (notificationResponse.actionId == exitActionId) {
debugPrint('close app');
SystemNavigator.pop();
}
}
For some reason SystemNavigator.pop(); is never called. Basically I want to close the app as well as a background service that I have running.