交互式通知UIMutableUserNotificationAction authenticationRequired无法在一个iphone ios 8.4

时间:2015-07-27 07:58:39

标签: ios objective-c iphone apple-push-notifications urbanairship.com

我们在iOS 8上使用交互式通知,我将authenticationRequired设置为Yes以进行交互式通知操作,因此用户应首先解锁他的手机以选择操作。

我们将我们的应用程序发布到HockeyApp进行测试。它安装在三个不同的iPhone 6上,全部带有最新的iOS 8.4所有iphone都有密码和启用TouchID以解锁手机。在两个iphone上它按预期工作,当一个推出屏幕被锁定以选择接受动作,例如用户应首先解锁他的手机(通过密码或TouchID)

但是在一部iphone上它并不需要解锁!用户可以执行操作。奇怪的是用户需要touchID或密码来解锁他的手机,但是对于通知动作它并不是。这是我们的代码,但我猜我们的代码很好,因为它在两部手机上按预期工作,但这里是代码,以防万一我们遗漏了一些东西:(我们正在使用UrbanAirship进行推送)

UAConfig *config = [UAConfig defaultConfig];
[UAirship push].userNotificationTypes = (UIUserNotificationTypeAlert |
                                         UIUserNotificationTypeBadge |
                                         UIUserNotificationTypeSound);
[UAirship takeOff:config];
[UAirship push].userPushNotificationsEnabled = YES;
[UAirship push].backgroundPushNotificationsEnabled = YES;


UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init];
acceptAction.destructive = NO;
acceptAction.activationMode = UIUserNotificationActivationModeBackground;
acceptAction.authenticationRequired = YES;
acceptAction.title = @"Accept";
acceptAction.identifier = NotificationAuthAcceptAction;

UIMutableUserNotificationAction *declineAction = [[UIMutableUserNotificationAction alloc] init];
declineAction.destructive = NO;
declineAction.activationMode = UIUserNotificationActivationModeBackground;
declineAction.authenticationRequired = YES;
declineAction.destructive = YES;
declineAction.title = @"Decline";
declineAction.identifier = NotificationAuthDeclineAction;

UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc] init];
[category setActions:@[acceptAction, declineAction] forContext:UIUserNotificationActionContextMinimal];
[category setActions:@[acceptAction, declineAction] forContext:UIUserNotificationActionContextDefault];
category.identifier = NotificationAuthCategory;

[UAirship push].userNotificationCategories = [NSSet setWithArray:@[category]];
[[UAirship push] updateRegistration];

1 个答案:

答案 0 :(得分:1)

这是iOS 8错误(雷达#18385104)。使用isEqual方法比较两个UIUserNotificationActions时,会将一些属性设置为要与之比较的对象。由于必须将所有类别放入集合中,因此isEqual方法适用于每个对象,因此可以针对任何操作修改authorizationRequired和destructive属性。

好消息是这个问题似乎在iOS 9中得到修复。

这是一个显示行为的单元测试 - https://github.com/urbanairship/ios-library-dev/blob/6.1.0/AirshipLib/AirshipLogicTests/IOS8BugsTests.m

相关问题