【问题标题】:Test Rich Notifications in Simulator在模拟器中测试丰富的通知
【发布时间】:2020-07-08 08:00:22
【问题描述】:

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

请您帮助我,如何进行。我需要更改任何模拟器设置吗? 我正在使用 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];
}

【问题讨论】:

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


    【解决方案1】:

    看着Xcode 11.4 release notes

    已知问题下:

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

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

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

    我自己使用了 PushNotifications,它奏效了。

    【讨论】:

    • 仅供参考 这在 12.5 Beta 中仍未修复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    相关资源
    最近更新 更多