【问题标题】:How to receive iOS10 Remote UserNotification如何接收 iOS 10 远程用户通知
【发布时间】:2026-02-15 19:55:01
【问题描述】:
{
  "aps": {
    "alert" : {
      "title": "Daily Sales",
      "body": "Bed"
    },
    "badge" : 1,
    "mutable-content": 1
  },
  "my-attachment" : "https://secure.img1.wfrcdn.com/lf/maxsquare/hash/36984/27677880/1/Wimbush-Panel-Bed-DBHC7470.jpg"
}

这是一个远程推送通知负载。当设备收到这个并由func didReceive(UNNotificationRequest, withContentHandler: (UNNotificationContent) -> Void)接收时,“我的附件”会直接进入content.attachments吗?如果我在 json 文件中添加更多自定义数据?会发生什么?

【问题讨论】:

标签: ios ios10 usernotifications


【解决方案1】:

您必须在Notification Service Extension file 中下载您的附件。您可以从中创建一个UNNotificationAttachment 对象,并传入UNNotificationServiceExtension 子类的func didReceiveNotificationRequest(request: UNNotificationRequest, withContentHandler contentHandler: (UNNotificationContent) -> Void) 方法的completionHandler。

【讨论】: