Geolocation return nothing


#1

Target Meizu u10, android 6
Geolocation returns data only from first starting app if I close app and start it again Geolocation returns nothing( no error, no resul). if I want get data again i need reboot my phone.

Someone had it?


#2

Did you test on other devices with different results?
Do other apps on this device have the same problem?
Show us some code…


#3

Do other apps on this device have the same problem? - No, even google.maps in the application show my position correctly.
At emulator and browser it is working fine but real device has a problem.
I created hollow project and he returns nothing too.
What I do wrong?

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Geolocation } from '@ionic-native/geolocation';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  providers: [Geolocation]
})
export class HomePage {

  constructor(public navCtrl: NavController,
  	private geolocation: Geolocation) {
  	geolocation.getCurrentPosition().then((resp) => {
	 console.log(resp)
	}).catch((error) => {
	  console.log('Error getting location', error);
	});

  }

}

also add code from my app

 public ngAfterViewInit() {
    this.diagnostic.isLocationAvailable()
      .then(res => {
        console.log(res)
        if (res) {
        
            this.geolocation.getCurrentPosition().then((resp) => {
             console.log(resp, 'resp');
            }).catch((error) => {
              console.log('Error getting location', error);
            });
    
         this.loadMap();
        }
      }); 
  }

#4

hmm…I have opened chrome and https://www.google.com/maps cant get my location too. Only native app can get it.


#5

Hi I was having the same problem, was driving me crazy. i rebooted the phone and everything was working fine since. Must be a bug.


#6

Keep in mind that aside from the native plugin, you are supposed to validate and authorize the app to use your geoloc coords before it can work (popup on your smartphone when you setup the app, with level of credentials like, authorize the app to use camera, geoloc, so on). So technically, if your app has no credentials, it will always return a null or zero value.

To confirm if this is the issue (or not), you can also test with Ionic View (it’s free), as it comes with built-in checks for that (set to yes, for that kind of checks).


#7

I have met the issue only at meizu u10, another devices work fine, so it’s bug from phone.
Btw, I resolved the issue by get geolocation from native google maps, Have added event at touch.


#8

Thx for the info, native plugins are much easier.