iOS 交互式通知所有操作不可见

iOS interactive notification all actions not visible

我有一个包含四个操作的交互式通知。

动作创建如下:

UIMutableUserNotificationAction *markAsReadAction = [[UIMutableUserNotificationAction alloc] init];
[markAsReadAction setActivationMode:UIUserNotificationActivationModeBackground];
[markAsReadAction setTitle:@"Mark As Read"];
[markAsReadAction setIdentifier:@"MarkAsReadIdentifier"];
[markAsReadAction setDestructive:NO];
[markAsReadAction setAuthenticationRequired:NO];

以同样的方式创建了其他三个动作,即 moveToTrashAction、replyAction 和 spamAction。

然后创建分类注册如下:

UIMutableUserNotificationCategory *mailOptionCategory = [[UIMutableUserNotificationCategory alloc] init];
[mailOptionCategory setIdentifier:@"MailOptionCategoryIdentifier"];
[mailOptionCategory setActions:@[markAsReadAction, moveToTrashAction, replyAction, spamAction]forContext:UIUserNotificationActionContextDefault];

NSSet *categories = [NSSet setWithObjects:MailOptionCategory, nil];
UIUserNotificationType types = (UIUserNotificationTypeAlert | UIUserNotificationTypeSound | UIUserNotificationTypeBadge);

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:categories];

if ([UIApplication instancesRespondToSelector:@selector (registerUserNotificationSettings:)]) {
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}

通知显示为警报时一切正常。

但如果通知显示为横幅或在通知中心查看。只有前两个操作(标记为已读和移至垃圾箱)可见。其余两个操作(回复和垃圾邮件)不可见。

关于问题,我是做错了什么还是默认的 iOS 行为?

我可以在通知中心查看通知或在横幅视图中显示通知时显示所有 4 个按钮吗?

提前致谢!

A​​pple 的 iOS Human Interface Guidelines 文档中提到:

In addition to a default action that users can take by tapping a banner, you can also define two actions that are revealed when users swipe the banner.

A notification alert is a standard alert view that appears onscreen and requires user interaction to dismiss. You supply the notification message and either a default action or up to four specific actions that are revealed when users tap the Options button.

所以你只限于这些数字,这是有道理的,因为在一行中填充四个操作会使用户很难点击正确的操作,而将其放在四个单独的行中(如警报视图)将占用太多了 space.