iOS中不显示交互式提醒选项

时间:2017-09-22 08:26:59

标签: ios objective-c uilocalnotification

我已为本地通知实施了交互式提醒。但这些交互式选项仅在设备解锁且用户在收到后立即下拉提醒时才可见。第一张图片在收到本地通知后立即显示。

Just after receiving

如果向左或向右滑动则没有任何反应。但如果你拉下来,那么你可以看到两个互动选项。就像在第二张图片中一样。

enter image description here

(Q1。)实际上,我的第一个问题是为什么在宣布三个互动选项时它只显示两个选项?

以下是我的相关代码。

UIMutableUserNotificationCategory *notificationCategory = [[UIMutableUserNotificationCategory alloc] init];
notificationCategory.identifier = mutableUserNotificationCategoryId;
[notificationCategory setActions:@[notificationAction1, notificationAction2, notificationAction3] forContext:UIUserNotificationActionContextDefault];
[notificationCategory setActions:@[notificationAction1, notificationAction2, notificationAction3] forContext:UIUserNotificationActionContextMinimal];

NSSet *categories = [NSSet setWithObjects:notificationCategory, nil];

UIUserNotificationType types = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:categories];
[application registerUserNotificationSettings:settings];

(Q2。)我的第二个问题是,当用户在任何其他阶段刷过通知时,为什么我们无法看到交互式选项。 (例如,通知中心下方的通知显示)请参阅我上传的下一张图片。

enter image description here enter image description here

1 个答案:

答案 0 :(得分:0)

如果使用UIUserNotificationActionContextMinimal,则通知警报将为此上下文显示不超过2个自定义操作。 Docs

在启用3​​D触控功能的设备上,下拉警报或使用3d-touch手势时,可以使用通知警报操作。您希望查看自定义操作的方式适用于非3D触控设备。

相关问题