Rn-fetch-blob: how to download files in background for iOS ?? IOSBackgroundTask: true not work for me, any one please help me out ??

Created on 27 Aug 2019  路  6Comments  路  Source: joltup/rn-fetch-blob

Hi ! Thank you for reporting an issue, but we would like to remind you, we have a trouble shooting page in our wiki.
You may want to take a look on that page or find issues tagged "trouble shooting" :p

  • please provide the version of installed library and RN project.
  • a sample code snippet/repository is very helpful to spotting the problem.
  • issues which have been tagged as 'needs feedback', will be closed after 2 weeks if receive no feedbacks.
  • issues lack of detailed information will be closed without any feedback

Most helpful comment

Hi,
after adding the following code in AppDelegate, i am able to upload file in background

//AppDelegate.h
@property (nonatomic, assign) UIBackgroundTaskIdentifier taskIdentifier;

// AppDelegate.m
- (void)applicationWillResignActive:(UIApplication *)application {
    if (self.taskIdentifier != UIBackgroundTaskInvalid) {
        [application endBackgroundTask:self.taskIdentifier];
        self.taskIdentifier = UIBackgroundTaskInvalid;
    }

    __weak typeof(self) weakSelf = self;
    self.taskIdentifier = [application beginBackgroundTaskWithName:nil expirationHandler:^{
        [application endBackgroundTask:weakSelf.taskIdentifier];
        weakSelf.taskIdentifier = UIBackgroundTaskInvalid;
    }];
}

here is my RNFetchBlob code
RNFetchBlob.config({ IOSBackgroundTask: true, }) .fetch('POST', videoPath, { 'ClientToken': access_token, 'Content-Type' : 'application/octet-stream', }, RNFetchBlob.wrap(fileUrl)) .then((res) => { console.log('res',res.text()) }) .catch((err) => { console.log('err',err) })

All 6 comments

@joltup

I am done with this https://github.com/Jacse/rn-fetch-blob#ios-background-uploading but still not working, please check if anyone has an idea @joltup

Thanks

Someone knows a library that works on background for ios?

Hi,
I am also looking for IOS background upload support, here is my code
RNFetchBlob.config({ IOSBackgroundTask: true, }) .fetch('POST', videoPath, { 'ClientToken': access_token, 'Content-Type' : 'application/octet-stream', }, RNFetchBlob.wrap(fileUrl)) .then((res) => { console.log('res',res.text()) }) .catch((err) => { console.log('err',err) })

while uploading data to server, if application is moved to background and again brining back to foreground RNFetchBlob callbacks are not getting called and showing loading continuously.

can anyone help me to fix this issue

Thanks

Hi,
after adding the following code in AppDelegate, i am able to upload file in background

//AppDelegate.h
@property (nonatomic, assign) UIBackgroundTaskIdentifier taskIdentifier;

// AppDelegate.m
- (void)applicationWillResignActive:(UIApplication *)application {
    if (self.taskIdentifier != UIBackgroundTaskInvalid) {
        [application endBackgroundTask:self.taskIdentifier];
        self.taskIdentifier = UIBackgroundTaskInvalid;
    }

    __weak typeof(self) weakSelf = self;
    self.taskIdentifier = [application beginBackgroundTaskWithName:nil expirationHandler:^{
        [application endBackgroundTask:weakSelf.taskIdentifier];
        weakSelf.taskIdentifier = UIBackgroundTaskInvalid;
    }];
}

here is my RNFetchBlob code
RNFetchBlob.config({ IOSBackgroundTask: true, }) .fetch('POST', videoPath, { 'ClientToken': access_token, 'Content-Type' : 'application/octet-stream', }, RNFetchBlob.wrap(fileUrl)) .then((res) => { console.log('res',res.text()) }) .catch((err) => { console.log('err',err) })

@venkataluri thanks it worked really. @mustafakemalelma

Was this page helpful?
0 / 5 - 0 ratings