4

我能够在模拟器中测试正常的通知,但是当我尝试测试丰富的通知时没有任何反应,事件标题没有得到更新。

你能帮我吗,如何进行。我需要更改任何模拟器设置吗?我正在使用 Xcode 11.4

样本有效载荷:

{
    "aps": {
        "mutable-content": 1,
        "alert": {
            "body": "Push notification body",
            "title": "Push notification title"
        }
    },
    "media-url": "https://i.imgur.com/t4WGJQx.jpg"
}

NotificationService 扩展方法:

- (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];
}
4

1 回答 1

9

查看Xcode 11.4 发行说明

已知问题下:

通知服务扩展在模拟推送通知中不起作用。不支持可变内容键。(55822721)

我猜你的后备是通过使用像PushNotifications这样的工具发送一个真正的通知来测试它,你需要:

  • 设备令牌
  • 捆绑标识符
  • 证书或令牌
  • 有效载荷
  • 选择正确的环境

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

于 2020-03-27T18:37:45.410 回答