小编dsa*_*thb的帖子

在模拟器中测试丰富的通知

我能够在模拟器中测试普通通知,但是当我尝试测试丰富的通知时,没有任何反应,事件标题没有更新。

你能帮我吗,如何继续。我需要更改任何模拟器设置吗?我正在使用 Xcode 11.4

示例有效负载:

{
    "aps": {
        "mutable-content": 1,
        "alert": {
            "body": "Push notification body",
            "title": "Push notification title"
        }
    },
    "media-url": "https://i.imgur.com/t4WGJQx.jpg"
}
Run Code Online (Sandbox Code Playgroud)

通知服务扩展方法:

- (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];
}
Run Code Online (Sandbox Code Playgroud)

xcode apple-push-notifications ios-simulator unnotificationserviceextension xcode11.4

4
推荐指数
1
解决办法
1181
查看次数