错误__NSCFLocalDownloadFile错误2创建临时

Mat*_*san 5 ios firebase nsurlsession nsurlsessiondownloadtask unnotificationattachment

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];
}
Run Code Online (Sandbox Code Playgroud)

我正在使用FCM进行推送通知.

{
"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
}
Run Code Online (Sandbox Code Playgroud)

这是我的有效载荷内容.

我使用NotificationExtension上面的代码,我用来从推送通知下载数据.

我从开发者证书中得到了成功的回复.如果我检查生产证书(用前一个更新)我得到这样的错误

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

如果我删除应用程序并再次运行它正在运行.但是,如果我使用新的IPA更新版本,它不会在通知中显示图像.

我想念的是,证书问题吗?是app权限问题吗?

我正在使用单独的APP ID(没有推送通知配置)UNNotificationServiceExtension.

更新

还检查了APNS也没有工作.

关于APNS和有效载荷内容的代码和解释很少

  1. Richmedia通知通知无法在生产证书中使用

  2. 更新IPA后,丰富的推送通知无法正常工作(相同的IPA与overirtten)

Mou*_*ian 0

我遇到了这个错误,它属于PESIXErrorDomain并且我很确定它是一个iOS错误,可能与其他错误一起在iOS 10中引入。

我实施的解决方法是使当前会话无效,启动一个新会话,并使用具有获取的恢复数据的新会话启动新的下载任务。