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和有效载荷内容的代码和解释很少
| 归档时间: |
|
| 查看次数: |
426 次 |
| 最近记录: |