Test Rich Notifications in Simulator

感情迁移 提交于 2021-02-04 07:29:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!