在模拟器中测试丰富的通知 [英] Test Rich Notifications in Simulator
问题描述
我能够在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];
}
推荐答案
在已知问题下:
Notification Service Extensions在模拟推送中不起作用 通知.可变内容密钥不适用. (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屋!