Local notification Triggers when an application is uninstalled and reinstalled

when I set the local notification for the upcoming time and when the application is uninstalled, the local notification starts when the application is installed. Is there any way to avoid this. Why is this happening?

+5
source share
3 answers

Perhaps in applicationDidFinishLaunching (not verified):

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

BOOL firstRun = [prefs boolForKey:@"firstRun"];

if(firstRun) {

    // Cancel all UILocalNotifications

} else {

    BOOL firstRun = NO;
    [prefs setBool:firstRun forKey:@"firstRun"];

}
+2
source

If the request was deleted when your application was deleted, you could [[UIApplication sharedApplication] cancelAllLocalNotifications];however, since this is not possible, I see no way ...

+1
source

didFinishLaunchingWithOptions, , .

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

   // BOOL firstRun=YES;

      BOOL firstRun = [prefs boolForKey:@"firstRun"];

    if(firstRun) {
                  NSArray *notificationarray  = [[UIApplication sharedApplication] scheduledLocalNotifications];

         BOOL firstRun =NO;
         [prefs setBool:firstRun forKey:@"firstRun"];

     } else {  
               BOOL firstRun = NO;
              [prefs setBool:firstRun forKey:@"firstRun"];
               NSArray *notificationarray  = [[UIApplication sharedApplication] scheduledLocalNotifications];
              NSLog(@"%@",notificationarray);

      } 

     [prefs  synchronize];

,

+1

All Articles