#If OBJC
-(void) setNotificationTag: (UILocalNotification*) localNotification: (NSString*) notificationTag {
NSArray *keys = @[@"key"];
NSArray *values = [NSArray arrayWithObject:notificationTag];
NSDictionary *uinfo = [NSDictionary dictionaryWithObjects:values forKeys:keys];
localNotification.userInfo = uinfo;
}
-(void) printLocalNotification: (UILocalNotification*) localNotification {
NSDictionary *uinfo = localNotification.userInfo;
NSLog(@"value = %@",[uinfo valueForKey:@"key"]);
}
-(NSString*) getNotificationTag: (UILocalNotification*) localNotification {
NSDictionary *uinfo = localNotification.userInfo;
NSString *str = [uinfo valueForKey:@"key"];
return str;
}
-(void) removeScheduledNotification: (NSString*) notificationTag {
UIApplication *app = [UIApplication sharedApplication];
NSArray *eventArray = [app scheduledLocalNotifications];
for (int i=0; i<[eventArray count]; i++) {
UILocalNotification* oneEvent = [eventArray objectAtIndex:i];
NSDictionary *userInfoCurrent = oneEvent.userInfo;
NSString *tag=[NSString stringWithFormat:@"%@",[userInfoCurrent valueForKey:@"key"]];
if ([tag isEqualToString:notificationTag]) {
//Cancelling local notification
NSLog(@"removing notification with tag = %@",tag);
[app cancelLocalNotification:oneEvent];
break;
}
}
}
#End If