从uilocalnotification中删除打开按钮

时间:2016-04-07 12:43:42

标签: ios objective-c uilocalnotification

我想删除"打开"来自警报通知的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];

谢谢

0 个答案:

没有答案