NativeScript / NativeScript/plugins

[background-http] events not fired on device

Open
#236 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
206
Forks
123
Avg merge
2d 1h
Merged PRs (30d)
1

Description

Hi,

I try to upload an image to a Server via backtround-http. It works correct on android and on iOS-Simulator, but on a real iOS-device, the task-events are not fired.

  • "@nativescript/ios": "8.1.0",
    
  • "@nativescript/background-http": "^5.0.2",
    
  • "@nativescript/core": "~8.1.5",
    

Simulator: iOS 15.2
Device: iOS 15.2.1

const bghttp = require("@nativescript/background-http");
let session = bghttp.session("file-upload");
let request = {
        url: this.backendURL + "images/",
        method: "POST",
        headers: imageHeaders,
        description: "multipart/form-data",
    }
let params = [
        { name: "file", filename: imagePath, mimeType: "image/png" }
    ];
let task = session.multipartUpload(params, request);
task.on("progress", function(e) {
            console.log("uploaded " + e.currentBytes + " / " + e.totalBytes);
        });

    task.on("error", function(e) {
        console.log("error!");
        console.log(e);
        console.log(e.response);
    });

    task.on("responded", function(request) {
        console.log("responded");
    }

Any ideas?

I can not reproduce it on severall smartphones/ipads, but have one device with this behavior...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the multipart upload on a real iOS device using the listed NativeScript, iOS, and background-http versions, then compare its progress, error, and responded callbacks with the simulator. Done means identifying why task events are absent on the affected device and confirming the callbacks behave correctly for the upload.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript, typescript
Domain
mobile, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.