title: how to call the snooze feature on the button click of alertview
body: <p>i have set an alarm through uilocalnotifications.so when my app is in background my local notification is displayed with 2 buttons close and view.when my app is in foreground it displays and alertview with 2 buttons ,stop and snooze.when the stop button is clicked i want that my alarm should stop and when snooze button is clicked i want that the notification should appear after 5 mins.How is this possible.Please help me in solving this prob.Thanks.</p>
  
  <pre><code>this is my code :
  
  
  //this is my controller class where i am setting my notification
  
  - (void)clearNotification {
  
      [[UIApplication sharedApplication] cancelAllLocalNotifications];
  }
  
  - (void)scheduleNotification {
  
      [reminderText resignFirstResponder];
      [[UIApplication sharedApplication] cancelAllLocalNotifications];
  
      Class cls = NSClassFromString(@"UILocalNotification");
      if (cls != nil) {
  
          UILocalNotification *notif = [[cls alloc] init];
          notif.fireDate = [datePicker date];
          notif.timeZone = [NSTimeZone defaultTimeZone];
  
          notif.alertBody = @"Did you forget something?";
          notif.alertAction = @"Show me";
          notif.soundName = UILocalNotificationDefaultSoundName;
          notif.applicationIconBadgeNumber = 1;
  
          NSInteger index = [scheduleControl selectedSegmentIndex];
          switch (index) {
              case 1:
                  notif.repeatInterval = NSMinuteCalendarUnit;
                  break;
              case 2:
                  notif.repeatInterval = NSHourCalendarUnit;
                  break;
              case 3:
                  notif.repeatInterval = NSDayCalendarUnit;
                  break;
              case 4:
                  notif.repeatInterval = NSWeekCalendarUnit;
                  break;
              default:
                  notif.repeatInterval = 0;
                  break;
          }
  
          NSDictionary *userDict = [NSDictionary dictionaryWithObject:reminderText.text
                                                  forKey:kRemindMeNotificationDataKey];
          notif.userInfo = userDict;
  
          [[UIApplication sharedApplication] scheduleLocalNotification:notif];
          [notif release];
      }
  }
  
  #pragma mark -
  #pragma mark === Public Methods ===
  #pragma mark -
  
  - (void)showReminder:(NSString *)text {
  
      if (reminderText != nil) {
  
          UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Reminder" 
                                                              message:text delegate:nil
                                                    cancelButtonTitle:nil
                                                    otherButtonTitles:@"stop",@"Snooze",nil];
          [alertView show];
          [alertView release];
  
  
  
      }
  
  
  
  
  }
  //this is my appdelegate where i am receiving my notification
  - (void)clearNotification {
  
      [[UIApplication sharedApplication] cancelAllLocalNotifications];
  }
  
  - (void)scheduleNotification {
  
      [reminderText resignFirstResponder];
      [[UIApplication sharedApplication] cancelAllLocalNotifications];
  
      Class cls = NSClassFromString(@"UILocalNotification");
      if (cls != nil) {
  
          UILocalNotification *notif = [[cls alloc] init];
          notif.fireDate = [datePicker date];
          notif.timeZone = [NSTimeZone defaultTimeZone];
  
          notif.alertBody = @"Did you forget something?";
          notif.alertAction = @"Show me";
          notif.soundName = UILocalNotificationDefaultSoundName;
          notif.applicationIconBadgeNumber = 1;
  
          NSInteger index = [scheduleControl selectedSegmentIndex];
          switch (index) {
              case 1:
                  notif.repeatInterval = NSMinuteCalendarUnit;
                  break;
              case 2:
                  notif.repeatInterval = NSHourCalendarUnit;
                  break;
              case 3:
                  notif.repeatInterval = NSDayCalendarUnit;
                  break;
              case 4:
                  notif.repeatInterval = NSWeekCalendarUnit;
                  break;
              default:
                  notif.repeatInterval = 0;
                  break;
          }
  
          NSDictionary *userDict = [NSDictionary dictionaryWithObject:reminderText.text
                                                  forKey:kRemindMeNotificationDataKey];
          notif.userInfo = userDict;
  
          [[UIApplication sharedApplication] scheduleLocalNotification:notif];
          [notif release];
      }
  }
  
  #pragma mark -
  #pragma mark === Public Methods ===
  #pragma mark -
  
  - (void)showReminder:(NSString *)text {
  
      if (reminderText != nil) {
          /*newtest *new = [[newtest alloc]initWithNibName:@"newtest" bundle:nil];
          [self.navigationController pushViewController:new animated:YES];
          [new release];*/
      //  - (void)alertView:(UIAlertView *)alert
  //  didDismissWithButtonIndex:(NSInteger) buttonIndex 
  //      {
  //          if (buttonIndex == 0)
  //          {
  //              NSLog(@"Cancel Tapped.");
  //          }
  //          else if (buttonIndex == 1) 
  //          {    
  //              NSLog(@"OK Tapped. Hello World!");
  //          }
  //      }
  
          UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Reminder" 
                                                              message:text delegate:nil
                                                    cancelButtonTitle:nil
                                                    otherButtonTitles:@"stop",@"Snooze",nil];
          [alertView show];
          [alertView release];
  
  
      }           
  </code></pre>
  
  <p>}</p>
  
  <p>-(void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex<br>
  {<br>
      NSString *title = [alertView buttonTitleAtIndex:buttonIndex];  </p>
  
  <pre><code>if(buttonIndex == 0)  
  {  
      NSLog(@"Button 1 was selected.");  
  }  
  else if([title isEqualToString:@"Button 2"])  
  {  
      NSLog(@"Button 2 was selected.");  
  }  
  </code></pre>
  
  <p>}  </p>
  
  <pre><code>//this is my appdelegate where i am receiving notification
  NSString *kRemindMeNotificationDataKey = @"kRemindMeNotificationDataKey";
  
  #pragma mark -
  #pragma mark === Application Delegate Methods ===
  #pragma mark -
  
  - (BOOL)application:(UIApplication *)application
      didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
  
      Class cls = NSClassFromString(@"UILocalNotification");
      if (cls) {
          UILocalNotification *notification = [launchOptions objectForKey:
                                  UIApplicationLaunchOptionsLocalNotificationKey];
  
          if (notification) {
              NSString *reminderText = [notification.userInfo 
                                        objectForKey:kRemindMeNotificationDataKey];
              [viewController showReminder:reminderText];
              /*newtest *new = [[newtest alloc]initWithNibName:@"newtest" bundle:nil];
              [window addSubview:new.view];*/
          }
      }
  
      application.applicationIconBadgeNumber = 0;
  
      [window addSubview:viewController.view];
      [window makeKeyAndVisible];
  
      return YES;
  }
  
  - (void)applicationWillEnterForeground:(UIApplication *)application {
  
      application.applicationIconBadgeNumber = 0;
  }
  
  - (void)application:(UIApplication *)application 
          didReceiveLocalNotification:(UILocalNotification *)notification {
  
      // UIApplicationState state = [application applicationState];
      // if (state == UIApplicationStateInactive) {
  
          // Application was in the background when notification
          // was delivered.
      // }
  
  
      application.applicationIconBadgeNumber = 0;
      NSString *reminderText = [notification.userInfo
                                objectForKey:kRemindMeNotificationDataKey];
      [viewController showReminder:reminderText];
       NSLog(@"Recieved Notification %@",notification);
  }
  </code></pre>