any other suggestion about this?
I started a new project with Ionic 2 and i’m struggling with the same problem.
I’ve tried everything on this topic.
For testing purpose, i decided to try with a starter template but everything goes in the same direction, i’m receiving the same error “Code: 3, Message: Timeout expired”. The only thing the app is trying to do is to retreive the current location with only the starter template with the plugins already installed.
Please see below the project’s information
ionic plugin --list
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
Your system information:
Cordova CLI: 7.0.1
Ionic Framework Version: 3.4.2
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.7
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: OS X El Capitan
Node Version: v6.10.2
Xcode version: Xcode 8.0 Build version 8A218a
Emulator: Nexus 5X API 25 Android 7.1.1
Code:
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { Geolocation } from '@ionic-native/geolocation';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(
public navCtrl: NavController,
public platform: Platform,
public geolocation: Geolocation) {}
ionViewDidEnter(){
this.platform.ready().then(() => {
console.log("Device is ready! View did enter!");
let options = {
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 0
}
this.geolocation.getCurrentPosition(options).then((resp) => {
console.log("My position: " + resp.coords.latitude + ", " + resp.coords.longitude);
}).catch((error) => {
console.log("Error getting location Code: " + error.code + ", Message: " + error.message);
});
});
}
}