通知操作按钮

时间:2017-08-24 14:42:43

标签: ios objective-c notifications uilocalnotification notification-action

我创建了UILocalNotification和UIMutableUserNotificationAction

如果我使用iphone,这个动作按钮似乎但我用ipad这个动作按钮似乎不是

UIMutableUserNotificationAction *action = [[UIMutableUserNotificationAction alloc]init];
    action.identifier = @"ActionNotification";
    action.title = @"START";
    action.activationMode = UIUserNotificationActivationModeForeground;



    UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategory alloc]init];
    categorys.identifier = @"alert";
    [categorys setActions:@[action] forContext:UIUserNotificationActionContextMinimal];


    UIUserNotificationSettings *setings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:[NSSet setWithObjects:categorys, nil]];


    [[UIApplication sharedApplication] registerForRemoteNotifications];
    [[UIApplication sharedApplication] registerUserNotificationSettings:setings];



    UILocalNotification *localNotification = [[UILocalNotification alloc] init];

    localNotification.fireDate = aIntervalDate;
    //localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5];
    localNotification.alertBody =@"Notification Test";
    localNotification.alertAction=@"START";
    localNotification.category=@"alert";
    localNotification.soundName = @"Reminder_Sound.mp3";
    localNotification.applicationIconBadgeNumber=1;
    // localNotification.hasAction=YES;
    NSDictionary *infoDict = @{@"title" : @"xxxxxx",
                               @"tipi" : @"yyyyy"};
    localNotification.userInfo = infoDict;
    localNotification.timeZone = [NSTimeZone systemTimeZone];
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

0 个答案:

没有答案