2016-09-16 72 views
0
{ 
    "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)時,「my-attachment」是否會直接進入content.attachments?如果我在json文件中添加更多自定義數據?會發生什麼?如何接收iOS10遠程用戶通知

+0

它不會直接在附件中,它會在通知內容的用戶信息中。參見:http://stackoverflow.com/questions/39399154/media-attachment-in-ios-10-push-notifications – dan

回答

0

你必須在Notification Service Extension file下載你的隨從。您可以創建一個UNNotificationAttachment對象,並傳遞給UNNotificationServiceExtension子類的func didReceiveNotificationRequest(request: UNNotificationRequest, withContentHandler contentHandler: (UNNotificationContent) -> Void)方法的completionHandler。