Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
petertoth-dev opened this issue Nov 20, 2024 · 1 comment

Comments

@petertoth-dev
Copy link

petertoth-dev commented Nov 20, 2024

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.

@petertoth-dev petertoth-dev changed the title Cannot watch location. Call "enableLocationRequest" first [Android] [@nativescript/geolocation] Cannot watch location. Call "enableLocationRequest" first Nov 20, 2024
@harfyt
Copy link

harfyt commented Nov 27, 2024

I had the same problem today after clean build of my app.
Please check the following issue that I opened in the nativescript-community/perms repo which I found to be responsible
nativescript-community/perms#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants