iphoneuilocalnotification

Piling up UILocalNotifications


I'm developping an app that sends tips to users every five minutes through UILocalNotifications. The problem is that if you don't use your phone for a while, the notifications pile up and when you unlock the phone, you have to dismiss them one after the other, which can become quite annoying if you haven't used the phone for quite a while. Clicking the action button on the Alert sends you back to the application but even then, you still have to go through all the notifications.

Is there any means of dismissing all the notifications that have already been fired with a single click ?

Thanks for your help.

Miky Mike


Solution

  • Well, actually, I realize I made a mistake.

    In order to cancel all the UIlocalNotifications at one, I just have to create this simple method : one line of code is enough :

     - (void)application:(UIApplication *)app didReceiveLocalNotification :(UILocalNotification *)notification {
    
    [[UIApplication sharedApplication] cancelAllLocalNotifications];
    }
    

    and there you are. Thanks anyway.