Issue with Geolocation

I’m trying to get the user’s position ( Latitude and Longitude) But for some reason it doesn’t work. It works in browser but not in phone or emulator. Here is my code.

         constructor(public navCtrl: NavController, public _http:Http, public alertCtrl:AlertController, public zone:NgZone, public platform:Platform, public loadingCtrl:LoadingController){        
  this.platform.ready().then(() => {
    if(navigator.geolocation){
        Geolocation.getCurrentPosition().then((position) => {

          console.log(position);
          }, (err) => {
            console.error(err);
          });
    }else{
      console.error("Navigator is unavailable");
    }
});}

After running application in console i don’t get any error because the if condition is true.

Version and Plugin
Cordova version 6.4.0
Ionic version 2.1.4
cordova-plugin-geolocation 2.4.0 “Geolocation”

Thank you.

see my example that works fine https://github.com/prolland006/ionic2-geoloc