首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在iOS 10上不可见的通知视图中的交互操作( xcode 8)

在iOS 10上不可见的通知视图中的交互操作( xcode 8)
EN

Stack Overflow用户
提问于 2016-10-06 18:39:42
回答 1查看 2.7K关注 0票数 0

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

提前感谢

代码语言:javascript
复制
        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 );
         }
     }];
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-06 22:11:27

在iOS 10中,当用户强制接触通知时,您的操作就会显示出来。试试看,你应该看看自己的行动。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39903424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档