问题
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.
Could you please assist me, how to proceed. Do I need to change any simulator settings? I am using Xcode 11.4
Sample Payload :
{
"aps": {
"mutable-content": 1,
"alert": {
"body": "Push notification body",
"title": "Push notification title"
}
},
"media-url": "https://i.imgur.com/t4WGJQx.jpg"
}
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];
}
回答1:
Looking at Xcode 11.4 release notes
Under Known Issues:
Notification Service Extensions do not work in simulated push notifications. The mutable-content key is not honored. (55822721)
I guess your fallback is to just test it by sending a real notification using a tool like PushNotifications where you need:
- device token
- bundle identifier
- certificate or token
- payload
- selection of correct environment
I used PushNotifications myself and it worked.
来源:https://stackoverflow.com/questions/60888395/test-rich-notifications-in-simulator