arun kumar
arun kumar

Reputation: 737

ionic2: geolocation in browser fails with error: EXCEPTION: Uncaught (in promise): false

I am working with geolocation plugin with ionic2. When the app loads in the browser, it asks for permission. But it does not get the position when getcurrentposition is called. I use FireFox browser.

The console log shows the error:

EXCEPTION: Uncaught (in promise): false

I need to pass the location if available or null to another function based on success or failure of the getcurrentlocation call.

Here is the code snippet:

 public test(){
 Geolocation.getCurrentPosition().then((resp) => {

 console.log (resp.coords.latitude);
 console.log (resp.coords.longitude);

  this.callclockin(resp.coords.latitude, resp.coords.longitude);    
 }).catch((error) => {
  this.callclockin("", "");   
 });
 }

Upvotes: 2

Views: 957

Answers (1)

CrsCaballero
CrsCaballero

Reputation: 2348

The plugin Geolocation is for device mobile

And for throw the catch in a device mobile look at my other answer in this link

Upvotes: 2

Related Questions