react-native-background-upload
react-native-background-upload copied to clipboard
Event listener 'completed' in background!! not being called
if the application is open, everything works very well, in 'progress' it shows the progress log and in the 'complete' event it also works, when it finishes uploading the file it shows the result, that it already uploaded the file.
Upload.startUpload({
url: url,
path: file,
method: 'POST',
field: "file",
type: "multipart",
parameters: {
....
},
maxRetries: 2, // set retry count (Android only). Default 2
headers: {
'content-type': 'multipart/form-data', // Customize content-type
'Accept': 'application/json'
},
notification: {
enabled: true,
notificationChannel: 'UploadMedia',
},
useUtf8Charset: true
}).then((uploadId) => {
Upload.addListener('progress', uploadId, (data) => {
console.log(`Progress: ${data.progress}%`)
})
Upload.addListener('error', uploadId, (data) => {
//console.log(`Error: ${data.error}%`)
})
Upload.addListener('cancelled', uploadId, (data) => {
//console.log(`Cancelled!`)
})
Upload.addListener('completed', uploadId, (data) => { //No Work in background Mode
count++
if (count == totalLoad) {
resolve(true)
}
console.log('Completed!')
})
}).catch((err) => {
console.log('Upload error!', err)
})
but if I send the information and close the application (background mode), if the work continues, the files keep uploading but the 'progress' and 'completed' events don't work
I'm pretty sure that's what this PR is trying to solve, which looks like it's making active progress.