ios: fix "Error when sending event: downloadBegin"

This commit is contained in:
Kesha Antonov
2022-06-14 17:17:23 +03:00
parent 95a7dddf77
commit 8f71d37809
2 changed files with 8 additions and 6 deletions
+7 -5
View File
@@ -353,11 +353,13 @@ RCT_EXPORT_METHOD(completeHandler:(nonnull NSString *)jobId
if (taskCofig != nil) {
if (!taskCofig.reportedBegin) {
NSDictionary *responseHeaders = ((NSHTTPURLResponse *)downloadTask.response).allHeaderFields;
[self sendEventWithName:@"downloadBegin" body:@{
@"id": taskCofig.id,
@"expectedBytes": [NSNumber numberWithLongLong: totalBytesExpectedToWrite],
@"headers": responseHeaders
}];
if (self.bridge) {
[self sendEventWithName:@"downloadBegin" body:@{
@"id": taskCofig.id,
@"expectedBytes": [NSNumber numberWithLongLong: totalBytesExpectedToWrite],
@"headers": responseHeaders
}];
}
taskCofig.reportedBegin = YES;
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "react-native-background-downloader",
"version": "2.4.1",
"version": "2.4.2",
"description": "A library for React-Native to help you download large files on iOS and Android both in the foreground and most importantly in the background.",
"main": "index.js",
"scripts": {