From 97a584155288b757a9b2f06de22e32f8b3ce24b4 Mon Sep 17 00:00:00 2001 From: Ali Moussa Date: Wed, 27 Mar 2019 13:16:29 +1100 Subject: [PATCH] Cancel notification before performing action to improve user experience --- src/Plugin.LocalNotifications.Android/LocalNotifications.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Plugin.LocalNotifications.Android/LocalNotifications.cs b/src/Plugin.LocalNotifications.Android/LocalNotifications.cs index fd0b7cd..a39642d 100644 --- a/src/Plugin.LocalNotifications.Android/LocalNotifications.cs +++ b/src/Plugin.LocalNotifications.Android/LocalNotifications.cs @@ -74,14 +74,14 @@ public static void ProcessIntent(Intent intent) var id = intent.GetStringExtra(LocalNotification.ActionId); var action = GetRegisteredActions(actionSetId)?.FirstOrDefault(a => a.Id == id); + // Cancel notification before performing action to improve user experience + CrossLocalNotifications.Current.Cancel(notificationId); + action?.Action(new LocalNotificationArgs { Parameter = intent.GetStringExtra(LocalNotification.ActionParameter), TimestampUtc = DateTime.UtcNow, }); - - // Cancel notification after performing action - CrossLocalNotifications.Current.Cancel(notificationId); } internal static IEnumerable GetRegisteredActions(string actionSetId) => _actionRegistrars?.FirstOrDefault(a => a.ActionSetId == actionSetId)?.RegisteredActions;