Ionic framework ionic2:浏览器中的地理定位失败,错误为:异常:未捕获(承诺中):false

Ionic framework ionic2:浏览器中的地理定位失败,错误为:异常:未捕获(承诺中):false,ionic-framework,firefox-addon,ionic2,Ionic Framework,Firefox Addon,Ionic2,我正在使用ionic2的地理定位插件。当应用程序加载到浏览器中时,它会请求权限。但是当调用getcurrentposition时,它没有得到位置。我使用FireFox浏览器 控制台日志显示错误: 例外:未捕获(承诺中):错误 我需要根据getcurrentlocation调用的成功或失败,将位置(如果可用)或null传递给另一个函数 以下是代码片段: public test(){ Geolocation.getCurrentPosition().then((resp) => { c

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

控制台日志显示错误:

例外:未捕获(承诺中):错误

我需要根据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
,请看下面我的另一个答案