ionic2:浏览器中的地理位置失败并显示错误:异常:未捕获(承诺):假



我正在使用ionic2的地理位置插件。当应用程序在浏览器中加载时,它会请求权限。但是当调用 getcurrentposition 时,它不会获得位置。我使用火狐浏览器。

控制台日志显示错误:

例外:未捕获(承诺中):假

我需要根据 getcurrentlocation 调用的成功或失败将位置(如果可用)或 null 传递给另一个函数。

以下是代码片段:

 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("", "");   
 });
 }
插件

Geolocation适用于移动设备

为了将catch扔到移动设备中,请查看我在此链接中的其他答案

最新更新