我想删除"打开"来自警报通知的app按钮。当用户设置通知并在应用处于后台时显示通知时,我想删除打开的按钮。
请看图片。这是通知触发时出现的默认警报。我想删除那个打开的按钮。
这是用户安排通知时的代码
-(void) scheduleLocalNotificationOnlyOneTime:(NSDate *)fireDate
{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.timeZone = [NSTimeZone localTimeZone];
localNotif.fireDate = fireDate;
if(!category){
localNotif.category = @"ACTIONABLECATEGORY";
}
else{
localNotif.category = @"ACTIONABLE";
}
localNotif.alertBody = @"Time Up";
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
这是我创建警报的代码
UIMutableUserNotificationAction *accept=[[UIMutableUserNotificationAction alloc] init];
[snooze setActivationMode:UIUserNotificationActivationModeBackground];
[snooze setTitle:@"Accept"];
[snooze setIdentifier:NotificationActionOneIdent];
[snooze setDestructive:NO];
[snooze setAuthenticationRequired:YES];
UIMutableUserNotificationAction *maybe=[[UIMutableUserNotificationAction alloc] init];
[watch setTitle:@"Maybe"];
[watch setActivationMode:UIUserNotificationActivationModeForeground];
[watch setIdentifier:NotificationActionTwoIdent];
[watch setDestructive:NO];
[watch setAuthenticationRequired:YES];
UIMutableUserNotificationAction *decline=[[UIMutableUserNotificationAction alloc] init];
[watch setTitle:@"Decline"];
[watch setActivationMode:UIUserNotificationActivationModeForeground];
[watch setIdentifier:NotificationActionTwoIdent];
[watch setDestructive:NO];
[watch setAuthenticationRequired:YES];
UIMutableUserNotificationCategory *actionCategory;
actionCategory = [[UIMutableUserNotificationCategory alloc] init];
[actionCategory setIdentifier:NotificationCategoryIdent];
[actionCategory setActions:@[decline, accept,maybe]
forContext:UIUserNotificationActionContextDefault];
谢谢