diff --git a/src/ios/FileUploader.h b/src/ios/FileUploader.h index aa17e3b0..139e321c 100644 --- a/src/ios/FileUploader.h +++ b/src/ios/FileUploader.h @@ -1,6 +1,7 @@ #import #import "UploadEvent.h" #import +#import NS_ASSUME_NONNULL_BEGIN @protocol FileUploaderDelegate @optional diff --git a/src/ios/FileUploader.m b/src/ios/FileUploader.m index ce2eae50..76bc9f85 100644 --- a/src/ios/FileUploader.m +++ b/src/ios/FileUploader.m @@ -36,14 +36,25 @@ -(id)init{ NSData* serverData = weakSelf.responsesData[@(task.taskIdentifier)]; NSString* serverResponse = serverData ? [[NSString alloc] initWithData:serverData encoding:NSUTF8StringEncoding] : @""; [weakSelf.responsesData removeObjectForKey:@(task.taskIdentifier)]; - [weakSelf saveAndSendEvent:@{ - @"id" : uploadId, - @"state" : @"UPLOADED", - @"statusCode" : @(((NSHTTPURLResponse *)task.response).statusCode), - @"serverResponse" : serverResponse, - @"uploadDuration" : @(duration) - }]; + if (isnumber(duration)) { + [weakSelf saveAndSendEvent:@{ + @"id" : uploadId, + @"state" : @"UPLOADED", + @"statusCode" : @(((NSHTTPURLResponse *)task.response).statusCode), + @"serverResponse" : serverResponse, + @"uploadDuration" : @(duration) + }]; + } else { + [weakSelf saveAndSendEvent:@{ + @"id" : uploadId, + @"state" : @"UPLOADED", + @"statusCode" : @(((NSHTTPURLResponse *)task.response).statusCode), + @"serverResponse" : serverResponse, + @"uploadDuration" : @"N/A" + }]; + } } else { + [weakSelf.responsesData removeObjectForKey:@(task.taskIdentifier)]; [weakSelf saveAndSendEvent:@{ @"id" : uploadId, @"state" : @"FAILED",