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

Error: Cannot enable the location service #107

Closed
rafusfx opened this issue Jan 24, 2018 · 3 comments
Closed

Error: Cannot enable the location service #107

rafusfx opened this issue Jan 24, 2018 · 3 comments

Comments

@rafusfx
Copy link

rafusfx commented Jan 24, 2018

Which platform(s) does your issue occur on?

Device - Android 7
Device - Android 4.3.3

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

  • CLI: 3.4.1
  • Cross-platform modules: 3.4.0
  • Runtime(s): 3.4.1
  • Plugin(s):
    "dependencies": {
    "@angular/animations": "~4.1.0",
    "@angular/common": "~4.1.0",
    "@angular/compiler": "~4.1.0",
    "@angular/core": "~4.1.0",
    "@angular/forms": "~4.1.0",
    "@angular/http": "~4.1.0",
    "@angular/platform-browser": "~4.1.0",
    "@angular/router": "~4.1.0",
    "nativescript-angular": "~3.0.0",
    "nativescript-geolocation": "^4.2.3",
    "nativescript-ng2-fonticon": "^1.3.4",
    "nativescript-plugin-firebase": "^5.1.3",
    "nativescript-telerik-ui": "^2.0.1",
    "nativescript-theme-core": "~1.0.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.3.0",
    "tns-core-modules": "^3.4.0",
    "zone.js": "~0.8.2"
    },
    "devDependencies": {
    "babel-traverse": "6.24.1",
    "babel-types": "6.24.1",
    "babylon": "6.17.1",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "~0.4.0",
    "typescript": "~2.2.1"
    }

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

On tapping the button to update location, it opens the popup asking to enable location (and most times it doesn't even ask), and than I get this error in the command line:

ERROR Error: Uncaught (in promise): Error: Cannot enable the location service
JS: Error: Cannot enable the location service
JS: at file:///data/data/org.nativescript.nativescriptng2drawerseed2/files/app/tns_modules/nativescript-geolocation/geolocation.js:168:32 [angular]
JS: at Object.onInvoke (file:///data/data/org.nativescript.nativescriptng2drawerseed2/files/app/tns_modules/@angular/core/bundles/core.umd.js:4156:37) [angular]
JS: at Object.onInvokeTask (file:///data/data/org.nativescript.nativescriptng2drawerseed2/files/app/tns_modules/@angular/core/bundles/core.umd.js:4147:37) [angular]

Is there any code involved?

import * as geolocation from "nativescript-geolocation";
import { Accuracy } from "ui/enums";

private getDeviceLocation(): Promise {
return new Promise((resolve, reject) => {
geolocation.enableLocationRequest().then(() => {
geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, maximumAge: 5000, timeout: 10000 }).then(location => {
resolve(location);
}).catch(error => {
reject(error);
});
});
});
}

public updateLocation() {
    this.getDeviceLocation().then(result => {
        this.latitude = result.latitude;
        this.longitude = result.longitude;
    }, error => {
        console.error(error);
    });
}
@rafusfx
Copy link
Author

rafusfx commented Jan 25, 2018

I have updated everything to the latest release...and now it works

@rafusfx rafusfx closed this as completed Jan 25, 2018
@burawi
Copy link

burawi commented Jan 27, 2018

I have the same issue and updated everything but still get this error

@DimitarTachev
Copy link
Contributor

Hi @burawi, check this comment: #93 (comment)

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

No branches or pull requests

3 participants