如何接收iOS10远程用户通知

时间:2016-09-16 20:44:53

标签: ios ios10 usernotifications

{
  "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文件中添加更多自定义数据?会发生什么?

1 个答案:

答案 0 :(得分:0)

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