xcode - 在模拟器中测试丰富的通知

标签 xcode apple-push-notifications ios-simulator xcode11.4 unnotificationserviceextension

我能够在模拟器中测试普通通知,但是当我尝试测试丰富的通知时,没有任何 react ,事件标题没有更新。
你能帮我吗,如何继续。我需要更改任何模拟器设置吗?
我正在使用 Xcode 11.4
示例有效负载:

{
    "aps": {
        "mutable-content": 1,
        "alert": {
            "body": "Push notification body",
            "title": "Push notification title"
        }
    },
    "media-url": "https://i.imgur.com/t4WGJQx.jpg"
}
通知服务扩展方法:
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
     self.contentHandler = contentHandler;
     self.bestAttemptContent = [request.content mutableCopy];
    
    self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]",
    self.bestAttemptContent.title];
}

最佳答案

看着 Xcode 11.4 release notes

已知问题:

Notification Service Extensions do not work in simulated push notifications. The mutable-content key is not honored. (55822721)



我想你的后备是通过使用像 PushNotifications 这样的工具发送一个真实的通知来测试它。您需要的地方:
  • 设备 token
  • 捆绑标识符
  • 证书或 token
  • 有效载荷
  • 选择正确的环境

  • 我自己使用 PushNotifications 并且它有效。

    关于xcode - 在模拟器中测试丰富的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60888395/

    相关文章:

    在 macOS 上使用 Swift 和 Electron

    xcode - 尝试在 OS X 上安装 Qt 给出 'You need to install Xcode 5.0.0' ,但这个版本太旧了,不可用

    iphone - 如何在 XCode 4 中删除文档 "iOs 4.2 Library"

    iphone - 如何在 iOS 中卸载我们的应用程序时收到通知

    iOS 使用 node-apn 为通知提供标题

    iphone - Default.png 显示在模拟器中但不显示在真实设备 iphone 上?

    ios - TextField becomeFirstResponder 不显示键盘

    iphone - 多任务处理后 AVAudioPlayer 继续播放

    ios - 在模拟器中使用 Xcode 5 构建 iOS 应用程序时,出现以下错误

    c# - PushSharp 不发送通知