NativeScript / NativeScript/plugins
[background-http] problems uploading images in the background
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 206
- Forks
- 123
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 1
Description
Hello I'm experiencing problems uploading images in the background when using background-http on iOS.
Here's how I implemented it:
Versions:
"@nativescript/core": "~8.0.0",
"@nativescript/background-http": "^5.0.2",
Implementation:
// filePath is the path to an image
const session = bghttp.session('image-upload')
let file = File.fromPath(filePath)
const params = [
{
name: 'files[]',
filename: filePath,
mimeType: 'image/jpeg'
}
]
const task = session.multipartUpload(params, uploadRequestOption)
let data = null
task.on('responded', e => {
data = e.data
})
task.on('complete', e => {
if (e.responseCode == 200) {
responseData = JSON.parse(data)
// ...
// ...
// ...
}
})
The implementation runs inside a loop.
It worked previously, and I'm not sure when it stopped.
I suspect it happened when I migrated from NS 6 to 8.
This works perfectly fine when the phone is open and the app is active, but when I lock the phone or go out of the app it stops running.
Any help with this is much appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported loop using background-http's session('image-upload') and multipartUpload entry points with the shown iOS versions, then compare behavior while the app is active and while the phone is locked or the app is backgrounded. Done means image uploads continue and the complete event receives a successful response when the app is not active.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100