NativeScript / NativeScript/plugins

[Android] [@nativescript/geolocation] Cannot watch location. Call "enableLocationRequest" first

Open
#606 1 comment 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

I call watchLocation properly after enableLocationRequest but I am getting Cannot watch location. Call "enableLocationRequest" first error message.

Other weird behavior:

  • It seems even if I allow the location permission, it forgets and requests it again.
  • the docs says watchLocation is now async in order to check for permissions before attempting to watch but this is meaningless this way, since still the callback sends the location, this part is very unclear, and I couldn't find any examples for v9
✔ Component nativescript has 8.8.2 version and is up to date.
✔ Component @nativescript/core has 8.8.6 version and is up to date.
✖ Component @nativescript/ios is not installed.
✔ Component @nativescript/android has 8.8.6 version and is up to date.
"@nativescript/geolocation": "^9.0.0",

Code:

    Geolocation.enableLocationRequest(true, true).then(() => {
      Geolocation.watchLocation(
        location => {
             console.log(location);
         },
        e => {
          console.log('watchLocation ERROR:', e);
        },
        {
          //Specifies desired accuracy in meters.
          desiredAccuracy: CoreTypes.Accuracy.any,
          updateDistance: 300,
          updateTime: 10000,
          minimumUpdateTime: 1000
        }
      ).then(()=>{
        console.log('WHAT IS THIS FOR?')
      })

UPDATE:
Downgrading to 8.3.1 solved all the issues and everything is working. I am on API 35.
So this is clearly a bug with 9.0.0 or the documentation is inaccurate and I should do something differently.

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 sample with @nativescript/geolocation 9.0.0 on Android API 35, then compare its behavior with version 8.3.1. Check the enableLocationRequest and watchLocation flow, including permission persistence; done means watching succeeds without the erroneous message and the documented async behavior is clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.