Avoid repeated push notifications


I have an Xamarin Forms that receives push notifications. The nature of those notifications are sensible to the time they are sent.
Imagine Microsoft Authenticator that receives notifications when you are authenticating with an account with 2 factor authentication.

When I send more than one push notification, on iOS I want to be able to dismiss older notifications and just keep the most recent one.

Is this handled on DidReceiveRemoteNotification method or is this too late for that? (don't know if this method is called before or after the notification shows on notification centre)

public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler){
// TODO: remove all notifications minus the most recent one.

Either way, how can I achieve being able to handle and remove the older push notifications?

Thanks in advance!

Best Answer


Sign In or Register to comment.