在模拟器中测试丰富的通知 [英] Test Rich Notifications in Simulator

本文介绍了在模拟器中测试丰富的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am able to test the normal notifications in Simulator, but when I tried to test rich notifications nothing happens, event title is not getting updated.

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

Could you please assist me, how to proceed. Do I need to change any simulator settings? I am using 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 扩展方法:

NotificationService Extension Method:

- (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 发行说明

已知问题下:

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

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

我猜您的后备方案是通过使用诸如 PushNotifications 之类的工具发送真实通知来测试它,其中你需要:

I guess your fallback is to just test it by sending a real notification using a tool like PushNotifications where you need:

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

我自己使用 PushNotifications 并且它有效.

I used PushNotifications myself and it worked.

这篇关于在模拟器中测试丰富的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆