From 80e15c4df6c0caee71014a47f8f8b6a32a379496 Mon Sep 17 00:00:00 2001 From: Cranyozen <61766249+cranyozen@users.noreply.github.com> Date: Sun, 31 Mar 2024 18:30:59 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BB=BF=F0=9F=94=A7=20Fix(notification.dart):?= =?UTF-8?q?=20Fix=20clicking=20twice=20to=20exit=20the=20application?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kitx_mobile/lib/services/notification.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kitx_mobile/lib/services/notification.dart b/kitx_mobile/lib/services/notification.dart index fd599fd..b44f4ca 100644 --- a/kitx_mobile/lib/services/notification.dart +++ b/kitx_mobile/lib/services/notification.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:awesome_notifications/awesome_notifications.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; @@ -51,7 +53,13 @@ class NotificationService { } } else if (key == 'action_view_exit') { // Exit app - SystemNavigator.pop(); // Probably not working on iOS (by Copilot) + instances.shutdownDevicesServer(); + + // Delete all notifications + AwesomeNotifications().cancelAll(); + + await SystemNavigator.pop(); // Probably not working on iOS (by Copilot) + exit(0); } } @@ -74,12 +82,14 @@ class NotificationService { NotificationActionButton( key: 'action_view_button', label: (serviceStatus == ServiceStatus.running) ? 'Public_Stop'.tr : 'Public_Launch'.tr, - actionType: ActionType.SilentAction, + actionType: ActionType.KeepOnTop, + autoDismissible: false, ), NotificationActionButton( key: 'action_view_exit', label: 'Public_Quit'.tr, actionType: ActionType.SilentAction, + autoDismissible: false, ), ]); }