Repeat alarm at particular time interval - iphone

Issue is, i put a date picker programmatically. In date picker i just used to display time from 1mins to 23 hours. User is supposed to set the time in the picker, and set up the notification.
Now,i get notification in background but only one time.I have to repeat time until timer will not stop.
I found too many links and source but not able to solve this issue
My Code:
In Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
application.applicationIconBadgeNumber = 0;
//------ Handle launching from a notification-------
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
self.localNotification =[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (self.localNotification)
{
application.applicationIconBadgeNumber = self.localNotification.applicationIconBadgeNumber-1;
NSLog(#"badge number: %d", application.applicationIconBadgeNumber);
[self playSoundWithNotification:self.localNotification];
}
else
{
[[UIApplication sharedApplication]cancelAllLocalNotifications];
}
}
didenterinbackground:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(#"Application entered background state.");
NSAssert(self->bgTask == UIBackgroundTaskInvalid, nil);
bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{
dispatch_async(dispatch_get_main_queue(), ^{
[application endBackgroundTask:self->bgTask];
self->bgTask = UIBackgroundTaskInvalid;
});
}];
dispatch_async(dispatch_get_main_queue(), ^{
while ([application backgroundTimeRemaining] > 1.0)
{
NSString *str_friend = #"Hello,";
if (str_friend)
{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif)
{
localNotif.alertBody = [NSString stringWithFormat:
NSLocalizedString(#"%# has a message for you.", nil), str_friend];
localNotif.alertAction = NSLocalizedString(#"Read Msg", nil);
localNotif.soundName = #"alarmsound.caf";
//localNotif.soundName =[NSString stringWithFormat:#"%#.mp3",str_Alarm];
localNotif.applicationIconBadgeNumber = 1;
[application presentLocalNotificationNow:localNotif];
NSLog(#"sound: %#, alertAction: %#, alerBody: %#",localNotif.soundName, localNotif.alertAction, localNotif.alertBody);
str_friend = nil;
break;
}
}
}
[application endBackgroundTask:self->bgTask];
self->bgTask = UIBackgroundTaskInvalid;
});
}
-
(void)playSoundWithNotification:(UILocalNotification *)notification
{
notification.soundName=[NSString stringWithFormat:#"%#.mp3",str_Alarm];
NSLog(#"soundname: %#",notification.soundName);
}
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif
{
testDate=notif.fireDate;
NSLog(#"DATE IS: %#, %#",testDate, notif.fireDate);
// Handle the notificaton when the app is running
NSLog(#"Recieved Notification %#",notif);
[self playSoundWithNotification:notif];
[self _showAlert:[NSString stringWithFormat:#"%#",str_Motivation] withTitle:#"Daily Achiever"];
}
- (void) _showAlert:(NSString*)pushmessage withTitle:(NSString*)title
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:pushmessage delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
if (alertView)
{
}
}
in myviewcontroller:
-(void)insert:(NSDate *)fire
{
appDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.localNotification = [[UILocalNotification alloc] init];
NSLog(#"localNotification %#", appDelegate.localNotification);
if (appDelegate.localNotification == nil)
return;
appDelegate.localNotification.fireDate = fire;
appDelegate.localNotification.timeZone = [NSTimeZone defaultTimeZone];
appDelegate.localNotification.alertBody = appDelegate.str_Motivation;
appDelegate.localNotification.alertAction = #"View";
appDelegate.localNotification.soundName = [NSString stringWithFormat:#"%#.mp3",appDelegate.str_Alarm];
appDelegate.localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber]+1;
NSLog(#"localNotification.alertBody %#", appDelegate.localNotification.alertBody);
NSLog(#"localNotification.soundName %#",appDelegate.localNotification.soundName);
[[UIApplication sharedApplication] scheduleLocalNotification:appDelegate.localNotification];
}
Please Help.

- (void)applicationDidEnterBackground:(UIApplication *)application
{
......
......
if (localNotif)
{
localNotif.alertBody = [NSString stringWithFormat:
NSLocalizedString(#"%# has a message for you.", nil), str_friend];
localNotif.alertAction = NSLocalizedString(#"Read Msg", nil);
localNotif.soundName = #"alarmsound.caf";
localNotif.applicationIconBadgeNumber = 1;
[localNotif setRepeatInterval:NSMinuteCalendarUnit];
[application presentLocalNotificationNow:localNotif];
str_friend = nil;
break;
}
}
I got solution.

Related

How to display notifications in status bar using dynamic data in iPhone?

In my app i am getting data using some network connection
i want to show that data in notification bar (status bar) in iPhone
so how to add data that i can see in status bar of iPhone when i drag it down
i search many tutorials but i did not find any good one please help me
Please tell me some ideas that i can manage my data in notification or any good tutorial
Please suggest any good tutorial so i can manage my dynamic data in notification bar
Thanks
After getting data:
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = date; // date after 10 sec from now
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif.alertBody = text; // text of you that you have fetched
// Set the action button
localNotif.alertAction = #"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:#"someValue" forKey:#"someKey"];
localNotif.userInfo = infoDict;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
To handle onclick of Noification:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
[window makeKeyAndVisible];
application.applicationIconBadgeNumber = 0;
// Handle launching from a notification
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSLog(#"Recieved Notification %#",localNotif);
}
return YES;
}
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
// Handle the notificaton when the app is running
NSLog(#"Recieved Notification %#",notif);
}
i think, uilocalnotificatios are deprecated. now you can use, UNUserNotificationCenter. we can add image to it as well as shown below:
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
UNAuthorizationOptions options = UNAuthorizationOptionAlert + UNAuthorizationOptionSound;
[center requestAuthorizationWithOptions:options
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (!granted) {
//NSLog(#"Something went wrong");
}
}];
int dayCounter =5;
int minute = 48;
{
NSDateComponents *components = [[NSDateComponents alloc] init];
components.weekday = dayCounter;
dayCounter++;
components.hour = 12;
components.minute = minute;
UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:YES];
UNMutableNotificationContent *objNotificationContent = [[UNMutableNotificationContent alloc] init];
objNotificationContent.title = [NSString localizedUserNotificationStringForKey:#"Notification!" arguments:nil];
objNotificationContent.body = [NSString localizedUserNotificationStringForKey:#"We made a surprise Edit for You" arguments:nil];
objNotificationContent.sound = [UNNotificationSound defaultSound];
objNotificationContent.badge = #([[UIApplication sharedApplication] applicationIconBadgeNumber] + 1);
UNNotificationAttachment *attachment = nil;
NSURL* outputURL = [[NSURL alloc] initFileURLWithPath:filePath];
NSError *attachmentError = nil;
attachment = [UNNotificationAttachment attachmentWithIdentifier:#"image"
URL: outputURL
options:nil
error:&attachmentError];
if (attachmentError) {
return;
}
objNotificationContent.attachments=#[attachment];
NSString *identifier = #"UYLLocalNotification";
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier
content:objNotificationContent trigger: trigger];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (error != nil) {
NSLog(#"Something went wrong: %#",error);
}
else
{
}
}];

UIlocalNotification did now appear without starting background task

I have a voip application.
I am using UILocalNotification in my application to alert notification for incoming call when application in background.
When application is in background, after getting an incoming call following function is called.
-(void)showLocalNotification:(NSNotification *)notification {
NSDictionary *dic = notification.userInfo;
NSString *msg = [dic objectForKey:#"msg"];
NSString *sound = [dic objectForKey:#"sound"];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *_localNotification = [[UILocalNotification alloc]init];
//setting the fire dat of the local notification
_localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:1];
//setting the time zone
_localNotification.timeZone = [NSTimeZone defaultTimeZone];
//setting the message to display
_localNotification.alertBody = msg;
//default notification sound
if ([sound length]==0) {
_localNotification.soundName = UILocalNotificationDefaultSoundName;
} else {
_localNotification.alertAction = NSLocalizedString(#"Receive", nil);
_localNotification.soundName = #"myringtone.aif";
}
//displaying the badge number
_localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication]applicationIconBadgeNumber]+1;
//schedule a notification at its specified time with the help of the app delegate
[[UIApplication sharedApplication]scheduleLocalNotification:_localNotification];
}
This function set a scheduleLocal notification to show an alert with two buttons Cancel and Receive which fires after a second.
Now the problem is:
This local notification appears to user only when a background task started as following
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication* app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
}
But after 10 minutes background task stops. Then local notification does not appear to user though it fires (A log prints after firing)
I did modify the applicationDidEnterBackground function as following to restart background task for long running. But unable.
- (void)applicationDidEnterBackground:(UIApplication *)application
{
expirationHandler = ^{
[app endBackgroundTask:self.bgTask];
self.bgTask = UIBackgroundTaskInvalid;
self.bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];
}
self.bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];
}
Now the questions are:
Is there any way which will fire local notification and appear to user when application is in background?
If background task is mandatory, how could be it long run to show local notification to appear user after 10 minutes?
I am using iPhone 3gs, iPhone 4 and iPhone 5.
Try This :
- (void)applicationDidEnterBackground:(UIApplication *)application
{
__block UIBackgroundTaskIdentifier bgTask ;
UIApplication *app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
pollingTimer2 = [NSTimer scheduledTimerWithTimeInterval:4.0f target:self selector:#selector(process) userInfo:nil repeats:YES];
}
-(void) process
{
[self didLocalNotification];
}
-(void)didLocalNotification
{
[[UIApplication sharedApplication]cancelAllLocalNotifications];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
if (localNotification == nil)
{
return;
}
NSLog(#"calling didLocalNotification");
localNotification.applicationIconBadgeNumber =0;
localNotification.alertBody =#"Message!";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:0];
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

Local Notification in background

Can anyone please tell me how to get a UILocalNotification while my app is in the background.
I am posting my code here. Thanks in advance.
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate =[startDate addTimeInterval:60];
NSLog(#"%#",localNotif.fireDate);
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertAction = #"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
NSString *notifStr=[NSString stringWithFormat:#"Hey looks like you're meeting up with %#, why don't you let your other friends know what fun they're missing out on? Share a photo :)",[itemDict objectForKey:#"fname"]];
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:notifStr ,#"notifKey",nil];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
-(void)insert:(NSDate *)fire
{
[[UIApplication sharedApplication]cancelAllLocalNotifications];
self.localNotification = [[UILocalNotification alloc] init];
if (self.localNotification == nil)
{
return;
}
else
{
self.localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60];
self.localNotification.alertAction = nil;
self.localNotification.soundName = UILocalNotificationDefaultSoundName;
self.localNotification.alertBody = #"Hey looks like you're meeting up with %#, why don't you let your other friends know what fun they're missing out on? Share a photo :)";
self.localNotification.alertAction = NSLocalizedString(#"Read Msg", nil);
self.localNotification.applicationIconBadgeNumber=1;
self.localNotification.repeatInterval=0;
[[UIApplication sharedApplication] scheduleLocalNotification:self.localNotification];
}
}
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif
{
[[UIApplication sharedApplication]cancelAllLocalNotifications];
app.applicationIconBadgeNumber = notif.applicationIconBadgeNumber -1;
notif.soundName = UILocalNotificationDefaultSoundName;
[self _showAlert:[NSString stringWithFormat:#"%#",Your msg withTitle:#"Title"];
}
- (void) _showAlert:(NSString*)pushmessage withTitle:(NSString*)title
{
[self.alertView_local removeFromSuperview];
self.alertView_local = [[UIAlertView alloc] initWithTitle:title message:pushmessage delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[self.alertView_local show];
if (self.alertView_local)
{
}
}
Hope this will help you :)
addTimerInterval is depcrecated in iOS 4.0, make sure you deployment target. You can use.
- (id)dateByAddingTimeInterval:(NSTimeInterval)ti
Also make sure you set the correct value for fireDate
Please Use below code.
self.localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60];
self.localNotification.alertAction = nil;
self.localNotification.soundName = UILocalNotificationDefaultSoundName;
self.localNotification.alertBody = #"Hey looks like you're meeting up with %#, why don't you let your other friends know what fun they're missing out on? Share a photo :)";
self.localNotification.alertAction = NSLocalizedString(#"Read Msg", nil);
self.localNotification.applicationIconBadgeNumber=1;
self.localNotification.repeatInterval=0;

UILocalNotification Object in DidFinishLaunching always nil?

I am creating a local notification for a specified date as follows
UILocalNotification *localNotify = [[UILocalNotification alloc]init];
[localNotify setFireDate:notificationDate];
[localNotify setTimeZone:[NSTimeZone localTimeZone]];
[localNotify setAlertBody:#"Daily Items Reminder"];
//[localNotify setAlertLaunchImage:#"blank_Btn"];
[localNotify setAlertAction:#"View"];
[localNotify setSoundName:UILocalNotificationDefaultSoundName];
[localNotify setApplicationIconBadgeNumber:1];
[localNotify setRepeatInterval:NSDayCalendarUnit];
NSDictionary *userDict = [NSDictionary dictionaryWithObject:#"dict"
forKey:#"key"];
localNotify.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotify];
[localNotify release];
In my ApplicationDidFinishLaunching i create an object for UILocalNotification as follows
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification)
{
NSInteger badgeNumber = notification.applicationIconBadgeNumber;
if (badgeNumber < 0)
{
notification.applicationIconBadgeNumber = 0;
}
else
{
notification.applicationIconBadgeNumber = badgeNumber - 1;
}
[self showAlertMessage:#"didFinishLaunchingWithOptions" withButtons:eOk forDelegate:self];
// open screen
}
}
After clicking on View Button when Local Notification appears the application starts, now launchOption should return the localnotification object thru the key but the it always returns nil as the alertview is not getting called??.. what am i possibly doing wrong??

how to call the snooze feature on the button click of alertview

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.
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];
}
}
-(void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if(buttonIndex == 0)
{
NSLog(#"Button 1 was selected.");
}
else if([title isEqualToString:#"Button 2"])
{
NSLog(#"Button 2 was selected.");
}
}
//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);
}
When you click your snooze button you set another local notification. When you click in snooze button you call another function. In this you take current time and in fire date you set it with adding 5 minutes.
When your notification is coming then u take one alert in received notification delegate method and the button click of alert u call this function
Click on your snooze alert click u call this function.
-(void)addNewNotification{
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody =#"HI"
localNotification.fireDate = [[NSDate date] dateByAddingTimeInterval:5*60];
localNotification.timeZone = [NSTimeZone localTimeZone];
localNotification.applicationIconBadgeNumber = localNotification.applicationIconBadgeNumber+1;
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
NSLog(#"%#",[[UIApplication sharedApplication] scheduledLocalNotifications]);
}
I think you should use the alertview delegate method,clickedAtIndex.
Then check if the index is what you want say 1 for snooze,then make it repeat after the 5 minutes.
Thanks