Skip to content

Commit

Permalink
Cancel notification before performing action to improve user experience
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-moussa committed Mar 27, 2019
1 parent 06c2822 commit 97a5841
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Plugin.LocalNotifications.Android/LocalNotifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LocalNotificationActionRegistration> GetRegisteredActions(string actionSetId) => _actionRegistrars?.FirstOrDefault(a => a.ActionSetId == actionSetId)?.RegisteredActions;
Expand Down

0 comments on commit 97a5841

Please sign in to comment.