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

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;
}