how to cancel all active notification tray when one notification is clicked

Pratik Shroff 1 Reputation point

Hi ,

I am developing push notification to Xamarin App. I am able to send notification from back end service to android mobile app. I want to cancel all notification sent from notification tray when one of the notification is clicked. I am very new to Xamarin App development. Also I want to handle notification when app is not running, app is in back ground OR app is in foreground. Right now I am just able to receive notification to my test device while debugging app to phone while connected to machine. I am using Xamarin form app using C# .Net, which is having android and iOS app.

Thanks ,

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,253 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Logesh Palani 1 Reputation point MVP

    ** iOS**
    There is no way to capture the notification dismiss because iOS won't allow you to wake up the application.

    DeleteIntent: DeleteIntent is a PendingIntent object that can be associated with a notification and gets fired when the notification gets deleted, either by :

    • User-specific action
    • User Delete all the notifications.

    You can set the Pending Intent to a broadcast Receiver and then perform any action you want.

    Intent intent = new Intent(this, MyBroadcastReceiver.class);  
      PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, intent, 0);  
      Builder builder = new Notification.Builder(this):  
     ..... code for your notification  


    public class MyBroadcastReceiver extends BroadcastReceiver {  
          public void onReceive(Context context, Intent intent) {  
                 .... code to handle cancel