ios - 通知服务扩展不工作

标签 ios objective-c iphone push-notification rich-notifications

我正在创建一个 iOS 应用程序( Objective-C 和 xcode 8.3)。我已经将推送通知与 firebase 集成在一起。它工作正常。现在我需要显示带有图像的通知(丰富的通知)。我创建了通知服务扩展。我在应用程序委托(delegate)中创建了类别标识符并将其设置到通知服务扩展的 info.plist 中。我还为 Notification Service Extension 启用了推送通知。我在通知负载中添加了“mutable_content”。问题是,当发送通知控件时,不会触发通知服务扩展部分。问题是什么?我错过了什么吗?我在 DidFinishLaunchingWithOption 中编写了以下代码块。

  UNNotificationCategory* generalCategory = [UNNotificationCategory
                                               categoryWithIdentifier:@"GENERAL"
                                               actions:@[]
                                               intentIdentifiers:@[]
                                               options:UNNotificationCategoryOptionCustomDismissAction];

    // Register the notification categories.
   UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
[center setNotificationCategories:[NSSet setWithObjects:generalCategory, nil]];

最佳答案

在您的负载中包含 "mutable-content": 1 并再次发送通知。

关于ios - 通知服务扩展不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46342291/

相关文章:

ios - 捏和旋转手势结束后如何将图像设置为原始状态?

iphone - 根据按下的按钮(iOS)检索自定义数据?

ios - 有什么方法可以禁用钱包通行证和 Android 支付中的共享通行证按钮吗?

iphone - 将 UIButton 添加到 MKAnnotationView

ios - iOS 的 NSPathControl 等效项

ios - __bridge_transfer 在 NULL 对象上是否有效

ios - 自定义水平弹出过渡无法正常工作

objective-c - iOS:如何设置 UILabel 的非系统字体系列、样式、大小?

ios - 自定义实现 DSLCalendarView for expedia like calendar

iphone - 使用旧款 iPhone 3G 测试,拔掉 sim 卡?