Skip to content

Commit 6fbc204

Browse files
authored
Merge pull request #61 from Vydia/remove-RN-warning
Remove iOS console warning and cleanup .m file
2 parents 19c16f6 + 3d29d36 commit 6fbc204

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

ios/VydiaRNFileUploader.m

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
//
2-
// VydiaRNFileUploader.m
3-
// Vydia
4-
//
5-
// Created by Kenneth Leland on 12/8/16.
6-
// Copyright © 2016 Vydia. All rights reserved.
7-
//
8-
91
#import <Foundation/Foundation.h>
102
#import <MobileCoreServices/MobileCoreServices.h>
113
#import <React/RCTEventEmitter.h>
@@ -24,9 +16,13 @@ @implementation VydiaRNFileUploader
2416
@synthesize bridge = _bridge;
2517
static int uploadId = 0;
2618
static RCTEventEmitter* staticEventEmitter = nil;
27-
static NSString *BACKGROUND_SESSION_ID = @"VydiaRNFileUploader";
19+
static NSString *BACKGROUND_SESSION_ID = @"ReactNativeBackgroundUpload";
2820
NSURLSession *_urlSession = nil;
2921

22+
+ (BOOL)requiresMainQueueSetup {
23+
return NO;
24+
}
25+
3026
-(id) init {
3127
self = [super init];
3228
if (self) {
@@ -88,7 +84,9 @@ - (void)_sendEventWithName:(NSString *)eventName body:(id)body {
8884
}
8985
}
9086

91-
// Borrowed from http://stackoverflow.com/questions/2439020/wheres-the-iphone-mime-type-database
87+
/*
88+
Borrowed from http://stackoverflow.com/questions/2439020/wheres-the-iphone-mime-type-database
89+
*/
9290
- (NSString *)guessMIMETypeFromFileName: (NSString *)fileName {
9391
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fileName pathExtension], NULL);
9492
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);
@@ -149,9 +147,9 @@ - (NSString *)guessMIMETypeFromFileName: (NSString *)fileName {
149147
[request setHTTPBody: httpBody];
150148

151149
// I am sorry about warning, but Upload tasks from NSData are not supported in background sessions.
152-
uploadTask = [[self urlSession:thisUploadId] uploadTaskWithRequest:request fromData: nil];
150+
uploadTask = [[self urlSession] uploadTaskWithRequest:request fromData: nil];
153151
} else {
154-
uploadTask = [[self urlSession:thisUploadId] uploadTaskWithRequest:request fromFile:[NSURL URLWithString: fileURI]];
152+
uploadTask = [[self urlSession] uploadTaskWithRequest:request fromFile:[NSURL URLWithString: fileURI]];
155153
}
156154

157155
uploadTask.taskDescription = customUploadId ? customUploadId : [NSString stringWithFormat:@"%i", thisUploadId];
@@ -206,10 +204,10 @@ - (NSData *)createBodyWithBoundary:(NSString *)boundary
206204
return httpBody;
207205
}
208206

209-
- (NSURLSession *)urlSession: (int) thisUploadId{
210-
if(_urlSession == nil) {
211-
NSURLSessionConfiguration *sessionConfigurationt = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:BACKGROUND_SESSION_ID];
212-
_urlSession = [NSURLSession sessionWithConfiguration:sessionConfigurationt delegate:self delegateQueue:nil];
207+
- (NSURLSession *)urlSession {
208+
if (_urlSession == nil) {
209+
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:BACKGROUND_SESSION_ID];
210+
_urlSession = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:self delegateQueue:nil];
213211
}
214212
return _urlSession;
215213
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-background-upload",
3-
"version": "4.1.0",
3+
"version": "4.2.0",
44
"description": "Cross platform http post file uploader with android and iOS background support",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)