UNNotificationServiceExtension有时不显示图像

我创build了UNNotificationServiceExtension子类来显示通知中的远程附件。 随机,附件不显示。

问题很难重现,但有些用户报告说,在收到带有图像附件的远程通知后,他们看不到图像。 经过一些debugging之后,我遇到了这个问题一次。 我注意到downloadTask()有空locationresponse的状态码是200

 override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { // ... // Dowload remote media file URLSession.shared.downloadTask(with: attachmentUrl) { (location: URL?, response: URLResponse?, error: Error?) in // ... self.contentHandler!(self.bestAttemptContent!) }.resume() } 

而且, errorvariables包含:

 "Error Domain=NSPOSIXErrorDomain Code=2 \"No such file or directory\" UserInfo={NSErrorFailingURLKey=https://<url_to_media_attachment>, NSErrorFailingURLStringKey=https://<url_to_media_attachment>}" 

似乎附件获取正确,但URLSession丢失获取附件的location URL。 我不知道这个问题的原因是什么。

我在真实设备iPhone 6S Plus,iOS 10.3.3上进行了testing。

有没有人有类似的问题? 任何build议我可以做什么不正确?