1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Image upload to server results in status 0 on Android but works on other platforms

Discussão em 'Angular' iniciado por Emerald, Outubro 16, 2024 às 03:22.

  1. Emerald

    Emerald Guest

    punchIn() {
    if (this.status === "CheckIn") {
    this.getCurrentCoordinates(() => {
    console.log("Coordinates received:", this.latitude, this.longitude);
    this.addPhoto("Check In")
    .then((photo: File) => {
    this.postDailyAttendance(photo);
    })
    .catch((error: any) => {
    console.error("Error capturing photo:", error);
    });
    });
    } else {
    this.getCurrentCoordinates(() => {
    console.log("Coordinates received:", this.latitude, this.longitude);
    this.addPhoto("Check Out")
    .then((photo: File) => {
    this.postDailyAttendance(photo);
    })
    .catch((error: any) => {
    console.error("Error capturing photo:", error);
    });
    });
    }
    }`I


    I'm developing a cross-platform app, and the image upload feature works fine on all platforms except Android.
    On Android, I'm encountering an issue where the request returns with a status code of 0, and the image upload fails. Here's what I've tried:

    1. The image upload works perfectly on emulator and web.
    2. I've tested the API, and it's working without any problems when called from other platforms.
    3. I'm using ionic-angular to handle the HTTP requests.

    What could be causing the status 0 error on Android while it works on other platforms?
    Are there specific configurations needed for Android that I'm missing?
    Could this be related to CORS, or is it a problem with Android network security?

    Continue reading...

Compartilhe esta Página