joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

background download is not working at all in iOS. #696

Open kp72-dev opened 3 years ago

kp72-dev commented 3 years ago
**Possible Unhandled Promise Rejection (id: 14):
Error: Lost connection to background transfer service
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:178977:34
__invokeCallback@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2848:23
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2553:34
__guard@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2761:15
invokeCallbackAndReturnFlushedQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2552:21
invokeCallbackAndReturnFlushedQueue@[native code]**

It is my error. i have tried all the solutions from issues and suggestion of other users but not affection at all.

Here is my CODE.

RNFetchBlob
                .config({
                    IOSBackgroundTask:true,
                    // add this option that makes response data to be stored as a file,
                    // this is much more performant.
                    fileCache: true,
                    indicator:true,
                    path: dirs + fileName
                })
                .fetch('GET', file.title, {
                    //some headers ..
                })
                .then((res) => {

                    console.log('The file saved to ', res.path())
                })

Tried solutions. https://koenig-media.raywenderlich.com/uploads/2016/09/BM-EnableBackgroundFetch.png https://github.com/joltup/rn-fetch-blob/issues/20 https://github.com/joltup/rn-fetch-blob/issues/234 https://github.com/joltup/rn-fetch-blob/issues/20 https://github.com/wkh237/react-native-fetch-blob/issues/448 Help if anyone can... @joltup

annucy commented 2 years ago

You can try the solution mentioned in https://github.com/joltup/rn-fetch-blob/issues/426.

Not completely understood the solution. But it worked for me.