5
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; 

@synchronized (session) 
{ 
    [[session downloadTaskWithURL:attachmentURL 
       completionHandler:^(NSURL *temporaryFileLocation, NSURLResponse *response, NSError *error) { 
        if (error != nil) { 
         NSLog(@"error.localizedDescription %@", error.localizedDescription); 
        } else { 
         NSFileManager *fileManager = [NSFileManager defaultManager]; 
         NSURL *localURL = [NSURL fileURLWithPath:[temporaryFileLocation.path stringByAppendingString:fileExt]]; 
         [fileManager moveItemAtURL:temporaryFileLocation toURL:localURL error:&error]; 

         NSError *attachmentError = nil; 
         attachment = [UNNotificationAttachment attachmentWithIdentifier:@"" URL:localURL options:nil error:&attachmentError]; 
         if (attachmentError) { 
          NSLog(@"attachmentError.localizedDescription %@", attachmentError.localizedDescription); 
         } 
        } 
        completionHandler(attachment); 
       }] resume]; 
} 

我正在使用FCM進行推送通知。錯誤__NSCFLocalDownloadFile錯誤2創建溫度

{ 
"to": "ffHjl2CblrI...", 
"data": { 
    "message": "Offer!", 
    "image": "https://media.giphy.com/media/l4lR0Q5u91kTNJPsA/giphy.gif", 
    "url": custom url, 
    "mediaType": "gif", 
    "type": "notification type" 
}, 
"notification": { 
    "body": "Body", 
    "sound": "default", 
    "title": "Title" 
}, 
"content_available": true, 
"mutable_content": true 
} 

這是我的有效內容內容。

我正在使用NotificationExtension上面的代碼,我正在使用它從推送通知下載數據。

我從開發者證書中得到了成功響應。如果我有生產許可證檢查(與前一個更新)我有錯誤這樣

__NSCFLocalDownloadFile: error 2 creating temp file: /private/var/mobile/Containers/Data/PluginKitPlugin/7D6B57B4-DC4D-4F3E-8113-C8469BA66BBB/tmp/CFNetworkDownload_NQQfGi.tmp

如果我刪除應用程序,然後再次運行它的工作。但是,如果我使用新的IPA更新版本,它不會在通知中顯示圖像。

我想念的是那個證書的問題?應用權限問題?

我爲UNNotificationServiceExtension使用了單獨的APP ID(沒有推送通知配置)。

更新

APNS到太不工作還檢查。

很少有更多的代碼,並解釋有關APNS和有效載荷內容

  1. Richmedia notification notification not working in production certifcate

  2. Rich push notification not work properlly after update IPA (same IPA with overwirtten)

回答

0

我也遇到過這種錯誤,這屬於PESIXErrorDomain和我」很確定這是一個可能在iOS 1中引入的iOS錯誤0以及other bugs

我已實施的解決方法是無效當前會話,開始一個新的會話,並開始與後天恢復數據的新會話創建一個新的下載任務。

+0

但是,這是工作的發展證書,也在應用商店認證(使用testflight)。 – user3589771

+0

我不知道它僅限於測試版本 – Mousavian