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

时间:2015-10-26 10:35:36

标签: ios iphone notifications

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

动作创建如下:

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];
}

当通知显示为警报时,一切都很好。

enter image description here

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

enter image description here

enter image description here

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

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

提前致谢!

1 个答案:

答案 0 :(得分:1)

在Apple的iOS Human Interface Guidelines文档中提到:

  

除了用户可以通过点按横幅广告时执行的默认操作,您还可以定义用户滑动横幅时显示的两个操作。

  

通知提醒是屏幕上显示的标准提醒视图,需要用户互动才能解除。您提供通知消息以及默认操作或用户点击“选项”按钮时显示的最多四个特定操作。

所以你只限于那些数字,这是有道理的,因为在一行中填充四个动作将使用户难以点击正确的一个,并且在四个单独的行(如警报视图)上进行操作会占用太多空间。

相关问题