我能够在模拟器中测试普通通知,但是当我尝试测试丰富的通知时,没有任何 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 这样的工具发送一个真实的通知来测试它。您需要的地方:
我自己使用 PushNotifications 并且它有效。
关于xcode - 在模拟器中测试丰富的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60888395/