我正在尝试实现通知框架,有没有人知道为什么我没有在交互式通知中获得两个操作按钮?当我向左滑动时,我只能看到“清除”按钮
提前致谢
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error)
{
if( !error )
{
NSLog( @"Push registration success." );
// create actions
UNNotificationAction *ackAction = [UNNotificationAction actionWithIdentifier:@"com.elonchan.yes"
title:@"Acknowledge"
options:UNNotificationActionOptionForeground];
UNNotificationAction *detailsAction = [UNNotificationAction actionWithIdentifier:@"com.elonchan.no"
title:@"Details"
options:UNNotificationActionOptionForeground];
NSArray *notificationActions = @[ ackAction, detailsAction ];
// create a category
UNNotificationCategory *inviteCategory = [UNNotificationCategory categoryWithIdentifier:@"com.elonchan.localNotification"
actions:notificationActions
intentIdentifiers:@[]
options:UNNotificationCategoryOptionCustomDismissAction];
NSSet *categories = [NSSet setWithObject:inviteCategory];
// registration
[center setNotificationCategories:categories];
[[UIApplication sharedApplication] registerForRemoteNotifications]; // required to get the app to do anything at all about push notifications
NSLog( @"Push rsetNotificationCategories success." );
}
else
{
NSLog( @"Push registration FAILED" );
NSLog( @"ERROR: %@ - %@", error.localizedFailureReason, error.localizedDescription );
NSLog( @"SUGGESTIONS: %@ - %@", error.localizedRecoveryOptions, error.localizedRecoverySuggestion );
}
}];
答案 0 :(得分:3)
在iOS 10中,当用户强制触摸您的通知时,您的操作会显示。试一试,你应该看看你的行动。