我有以下代码,但通知出来后,我无法取消图标徽章。为了启动应用程序、取消通知和重置图标徽章,我应该添加什么代码?
另一个问题是为什么通知只出现在手机的主屏幕上?在应用程序中,通知不会显示。谢谢。
display.text=[NSString stringWithFormat:@"%@A",display.text];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Utilities" message:@"Alarm added" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
// optional - add more buttons:
[alert show];
UILocalNotification *localNotification = [[UILocalNotification alloc] init]; //Create the localNotification object
NSDate *date = [NSDate date];
// Add one minute to the current time
NSDate *dateToFire = [date dateByAddingTimeInterval:20];
// Set the fire date/time
[localNotification setFireDate:dateToFire];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
[localNotification setAlertAction:@"Done"];
[localNotification setAlertBody:@"(A)"];
[localNotification setHasAction: YES];
[localNotification setSoundName:UILocalNotificationDefaultSoundName];
[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];