我目前正在開發由8製作的交互式iOS通知,說實話,我真的很難看到我的按鈕。 用下面的代碼,我看不到我的按鈕:iOS自定義按鈕不顯示爲交互式通知
// INTERACIVE
UIMutableUserNotificationAction *acceptAction =
[[UIMutableUserNotificationAction alloc] init];
acceptAction.identifier = @"ACCEPT_IDENTIFIER";
acceptAction.title = @"Accept";
acceptAction.activationMode = UIUserNotificationActivationModeBackground;
acceptAction.destructive = NO;
acceptAction.authenticationRequired = NO;
UIMutableUserNotificationAction *maybeAction =
[[UIMutableUserNotificationAction alloc] init];
maybeAction.identifier = @"MAYBE_IDENTIFIER";
maybeAction.title = @"Maybe";
maybeAction.activationMode = UIUserNotificationActivationModeBackground;
maybeAction.destructive = NO;
maybeAction.authenticationRequired = YES;
UIMutableUserNotificationAction *declineAction =
[[UIMutableUserNotificationAction alloc] init];
declineAction.identifier = @"DECLINE_IDENTIFIER";
declineAction.title = @"Decline";
declineAction.activationMode = UIUserNotificationActivationModeBackground;
declineAction.destructive = YES;
declineAction.authenticationRequired = NO;
UIMutableUserNotificationCategory *inviteCategory =
[[UIMutableUserNotificationCategory alloc] init];
inviteCategory.identifier = @"INVITE_CATEGORY";
[inviteCategory setActions:@[acceptAction, maybeAction, declineAction]
forContext:UIUserNotificationActionContextDefault];
[inviteCategory setActions:@[acceptAction, declineAction]
forContext:UIUserNotificationActionContextMinimal];
NSSet *categories = [NSSet setWithObjects:inviteCategory, nil];
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:categories];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
localNotification.alertBody = @"Testing";
localNotification.category = @"INVITE_CATEGORY"; // Same as category identifier
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
我的問題任何想法? 儘管在互聯網上的所有例子,我顯然是唯一一個這個問題。
您的教程有效!謝謝你,兄弟! – NiClou 2014-10-23 13:17:46
我想在第二個'snoozeable.setActions([openAction,snoozeAction],forContext:.Default)',你打算用'.Minimal'替換'.Default'。 'notSnoozable'也一樣。 – MichaelScaria 2015-06-05 18:21:04
@Stephen:您是否知道提醒應用程序是如何決定是使用「最小」上下文還是使用「默認」上下文的操作類別? – 2015-10-11 04:12:50