【问题标题】:Interactive actions in notification view not visible on iOS 10 ( xcode 8)通知视图中的交互操作在 iOS 10(xcode 8)上不可见
【发布时间】:2016-10-06 18:39:42
【问题描述】:

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

提前致谢

        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 objective-c apple-push-notifications unusernotificationcenter


    【解决方案1】:

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

    【讨论】:

    • 帕特里克,谢谢!你是对的。很抱歉迟到接受答案,即使我在第二天看到你的答案......
    猜你喜欢
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    • 1970-01-01
    相关资源
    最近更新 更多