Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

watchLocation method doesn't get location in background mode android #256

Open
@bhoomiJagani

Description

@bhoomiJagani

Which platform(s) does your issue occur on?
Android
Android 10
Device Moto G(2nd Generation)

Please, provide the following version numbers that your issue occurs with:
CLI: 8.3.18

In, package.json
"nativescript-geolocation": "^5.1.0",

Please, tell us how to recreate the issue in as much detail as possible.

I'm using Geolocation apis to get location in background in android. When I call watchLocation in foreground, it's giving location, but when app goes to background, I didn't get any location. I am displaying location in console.log. For ios, when app goes in background mode, it's display log of location. I am using nativescript with angular.

Is there any code involved?

public buttonStartTap() {
   console.log("buttonStartTap");
   try {
     let that = this;
     this.watchIds.push(geolocation.watchLocation(
       function (loc) {
         if (loc) {
           that.locations.push(loc);
           console.log("loc", loc);
         }
       },
       function (e) {
         console.log("Error: " + e.message);
       },
       {
         desiredAccuracy: Accuracy.high,
         updateDistance: 1,
         updateTime: 3000,
         minimumUpdateTime: 100,
         iosAllowsBackgroundLocationUpdates: true,
         iosPausesLocationUpdatesAutomatically: false,

       }));
   } catch (ex) {
     console.log("Error: " + ex.message);
   }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions