Vydia / react-native-background-upload

Upload files in your React Native app even while it's backgrounded. Supports Android and iOS, including camera roll assets.
MIT License
721 stars 325 forks source link

Background upload not working when phone is not connected to WIFI #299

Open haibert opened 2 years ago

haibert commented 2 years ago

Hello,

Thank you for this awesome library. I am having a rough time right now, I worked with the backend to implement background uploads for 2 days straight and now we've realized that the uploads don't work if they phone is not connected to Wifi. Im just curious, is this expected behavior or if its a feature the library is lacking? I was reading some articles about native iOS development and saw that it should be possible to keep the upload going even if on cellular data, not sure what to do.. any help would be appreciated


NSURLSessionConfiguration *backgroundConfig = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:identifier];
//Determines the maximum number of simulataneous connections to a Host. This is a per session property.
backgroundConfig.HTTPMaximumConnectionsPerHost = 1;
// This controles whether you are allowed to continue your upload/download over cellular access.
backgroundConfig.allowsCellularAccess = YES;
// This makes sure you get an event on your app session launch (in your AppDelegate). (Your app might be killed by system even if your upload/download is going on)
backgroundConfig.sessionSendsLaunchEvents = YES;
// This tells the system to wait for connectivity and then resume uploading/downloading. If the network goes away, it will restart from 0.
backgroundConfig.waitsForConnectivity = YES;
// This just makes a new url session using the background configuration.
NSURLSession *urlSession = [NSURLSession sessionWithConfiguration:backgroundConfig delegate:self delegateQueue:[NSOperationQueue mainQueue]];