ios - 通知 View 中的交互操作在 iOS 10 ( xcode 8) 上不可见

标签 ios objective-c apple-push-notifications unusernotificationcenter

我正在尝试实现通知框架,有谁知道为什么我在交互式通知中没有获得两个操作按钮?当我向左滑动时,我只能看到“清除”按钮

提前致谢

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

最佳答案

在 iOS 10 中,当用户用力触摸您的通知时,您的操作就会显示出来。试一试,您应该会看到自己的行为。

关于ios - 通知 View 中的交互操作在 iOS 10 ( xcode 8) 上不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39903424/

相关文章:

c++ - Xcode 配置文件不适用于汇编代码

ios - iOS 8.0 公开版本的内部版本号是多少?

ios - 向对象数组添加二级排序

iOS - 如何在客户端服务器聊天应用程序中正确使用后台获取和远程通知?

ios - 以编程方式生成 APNS 证书

iphone - UIImageView 显示动画期间相机以错误的方向拍摄的图像

objective-c - 通过 Cocoa 中的 NSURLRequest/NSURLConnection 接收 HTTP header

objective-c - 具有 __attribute__((NSObject)) 的 CF 类型的强@property 不保留

objective-c - RestKit - fetchFromDataStore(缓存)问题

PHP 警告 : pack(): Type H: illegal hex digit r error