Error: Uncaught (in promise): [object PositionError] Geolocation

Hi, I am getting an error which seems to indicate that I am not catching a promise but I verified that all places I use this provider function there is a catch.

export class Location {
  constructor(public latitude?:number,
              public longitude?:number) {
  }
}

@Injectable()
export class PhoneLocation {

  getLocation() {
    return new Promise((resolve, reject)=> {
      Geolocation.getCurrentPosition({timeout: 20000, enableHighAccuracy: false})
        .then((position) => {
          resolve(new Location(position.coords.latitude, position.coords.longitude));
          return;
        })
        .catch(
          (err) => {
            console.error('Could not read current location');
            reject(err);
          });
    });
  }

Error-
Error: Uncaught (in promise): [object PositionError] Geolocation

Configuration-
“dependencies”: {
"@angular/common": “2.1.1”,
"@angular/compiler": “2.1.1”,
"@angular/compiler-cli": “2.1.1”,
"@angular/core": “2.1.1”,
"@angular/forms": “2.1.1”,
"@angular/http": “2.1.1”,
"@angular/platform-browser": “2.1.1”,
"@angular/platform-browser-dynamic": “2.1.1”,
"@angular/platform-server": “2.1.1”,
"@ionic/storage": “1.1.6”,
“angular2-google-maps”: “^0.16.0”,
“ionic-angular”: “2.0.0-rc.3”,
“ionic-native”: “2.2.6”,
“ionicons”: “^3.0.0”,
“rxjs”: “5.0.0-beta.12”,
“zone.js”: "0.6.

Any ideas?

Try dumping out the err.code and err.message
What’s the message in there?

1 Like

You know what is weird I put the “–dev” option on the ionic build scripts and I haven’t seen the error since.

You are needlessly creating an extra promise.

4 Likes

It would possibly be an “[Violation] Only request geolocation information in response to a user gesture.”

Only the polyfill-es2015 warns about that, the error itself it’s blank, also the error handling seems to stop the propagation of the subsequent events.