Reputation: 91
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];
}
Upvotes: 9
Views: 3321
Reputation: 36257
Simulator now supports remote notifications in iOS 16 when running in macOS 13 on Mac computers with Apple silicon or T2 processors. Simulator supports the Apple Push Notification Service Sandbox environment. Your server can send a remote notification to your app running in that simulator by connecting to the APNS Sandbox (api.sandbox.push.apple.com). Each simulator generates registration tokens unique to the combination of that simulator and the Mac hardware it’s running on. See User Notifications for more information.
Remote Notifications support more features (like Notification Service Extensions) than locally simulated notifications using
.apns
payload files or thesimctl
push command.
Based on docs starting from Xcode14:
See older revision of this answer for Older Xcode versions up to Xcode 13.
Upvotes: 14