actually am developing an alarm project, now i have a doubt on Local notification. how can i identify a particular notification. we can't even set tag to local notification then how can i differentiate them.
example:
notification:1
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = selectedDate;
localNotification.alertBody = @"you got work";
localNotification.alertAction = @"Snooze";
localNotification.repeatInterval = NSDayCalendarUnit;
localNotification.soundName = UILocalNotificationDefaultSoundName;
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"setNotificationForEveryDay", @"key", nil];
localNotification.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
notification:2,
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = another selectedDate;
localNotification.alertBody = @"i got work";
localNotification.alertAction = @"Snooze";
localNotification.repeatInterval = NSDayCalendarUnit;
localNotification.soundName = UILocalNotificationDefaultSoundName;
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"setNotificationForEveryDay", @"key", nil];
localNotification.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
now i'm in situation to delete the second notification how can i do it... please help me.. thanks in advance..
An iOS push notification is a message that pops up on an Apple device such as an iPhone. Before receiving push notifications from an app, iOS device users must explicitly give permission. Once a user opts-in, mobile app publishers can send push notifications to the users' mobile devices.
Notifications help you keep track of what's new—they let you know if you missed a call, if the date of an event moved, and more. You can customize your notification settings so you see only what's important to you.
Local notifications are scheduled by an app and delivered on the same device. They are suited for apps with time-based behaviors, such as calendar events. When you run your app on a device with Android OS 8.0 or above, Kony uses default channels that are mentioned in the localnotificationconfig.
My guess is that use the userInfo for distinguishing the local notifications that would be a better idea but for that you need to set the userInfo of the local notification.
Like you could do something like this
if ([Your_notification_Object.userInfo valueForKey:@"Key 1"]==@"Object 1") { NSLog(@"This is notification 1"); }
now for your second requirement i.e for the deleting part do you want to delete the notification when it is identified as n1 or n2 then in that case you could modify the above code and add this
if ([Your_notification_Object.userInfo valueForKey:@"Key 1"]==@"Object 1") { NSLog(@"This is notification 1"); [[UIApplication sharedApplication] cancelLocalNotification:Your_notification_Object]; }
Place the above code as per your convenience
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With