Friday, 13 September 2013

One notification work and cancel the other notifications

One notification work and cancel the other notifications

I am having a problem here guys which is I'm trying to do three
notification with sounds and what i want to do is when the S1 button or S2
or S3 one of them pressed i want to cancel the other two notification
help please with details because im confused
}
-(void)scheduleLocalNotificationWithDate:(NSDate *)fireDate
{
UILocalNotification *notifiction = [[UILocalNotification alloc]init];
notifiction.FireDate = fireDate;
notifiction.AlertBody = @" ";
notifiction.soundName = NSUserDefaultsDidChangeNotification;
notifiction.repeatInterval= NSMinuteCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification: notifiction];
NSLog(@" ");
}
(IBAction)SetBtn:(id)sender
{
NSDateFormatter *dateFormatter =[ [NSDateFormatter alloc] init];
dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterShortStyle;
NSString *dateTimeString = [dateFormatter stringFromDate:
dateTimePicker.date];
[self scheduleLocalNotificationWithDate:dateTimePicker.date];
}
(IBAction)S1:(NSDate *) fireDate;
{
soundNumber = 1; [[NSUserDefaults standardUserDefaults] setObject:@"S1"
forKey:@"UserSoundChoice"]; UILocalNotification *localNotification1 =
[[UILocalNotification alloc] init]; [localNotification1
setFireDate:[NSDate date]]; [localNotification1 setTimeZone:[NSTimeZone
defaultTimeZone]]; [localNotification1 setAlertBody:@"Wake up!!"];
[localNotification1 setAlertAction:@"View"]; [localNotification1
setHasAction:YES]; localNotification1.repeatInterval=
NSMinuteCalendarUnit; localNotification1.soundName= [[NSUserDefaults
standardUserDefaults] objectForKey:@"UserSoundChoice"]; [[UIApplication
sharedApplication] scheduleLocalNotification:localNotification1];
}
(IBAction)S2:(NSDate *) fireDate;
{
soundNumber = 2; [[NSUserDefaults standardUserDefaults] setObject:@"S2"
forKey:@"UserSoundChoice"]; UILocalNotification *localNotification2 =
[[UILocalNotification alloc] init]; [localNotification2
setFireDate:[NSDate date]]; [localNotification2 setTimeZone:[NSTimeZone
defaultTimeZone]]; [localNotification2 setAlertBody:@"Wake up!!"];
[localNotification2 setAlertAction:@"View"]; [localNotification2
setHasAction:YES]; localNotification2.repeatInterval=
NSMinuteCalendarUnit; localNotification2.soundName= [[NSUserDefaults
standardUserDefaults] objectForKey:@"UserSoundChoice"]; [[UIApplication
sharedApplication] scheduleLocalNotification:localNotification2];
}
-(IBAction)S3: (NSDate *) fireDate;
{
soundNumber = 3;
[[NSUserDefaults standardUserDefaults] setObject:@"S3"
forKey:@"UserSoundChoice"];
UILocalNotification *localNotification3 = [[UILocalNotification alloc] init];
[localNotification3 setFireDate:[NSDate date]];
[localNotification3 setTimeZone:[NSTimeZone defaultTimeZone]];
[localNotification3 setAlertBody:@""];
[localNotification3 setAlertAction:@"View"];
[localNotification3 setHasAction:YES];
localNotification3.repeatInterval= NSMinuteCalendarUnit;
localNotification3.soundName= [[NSUserDefaults standardUserDefaults]
objectForKey:@"UserSoundChoice"];
[[UIApplication sharedApplication]
scheduleLocalNotification:localNotification3];
}

No comments:

Post a Comment