Geolocation doesn't work

Hi, i have a problem in geolocation, currently i am running on ionic 4.12,I install apk on android 6 and 9 and it is working fine, but when i install it on android 4.4 and 5 the geolocation is not working, there is no return value.

please help

So a few things…

  1. Why can’t guess what the issue is. Could you recreate it in a sample project and push that to github?
    Or at least share some code.
  2. Android 4.4 is not supported. This is not really relevant to your current issue, but something to keep in mind.
import { Component, OnInit } from '@angular/core';
import { Geolocation } from '@ionic-native/geolocation/ngx';

@Component({
  selector: 'app-test-loc',
  templateUrl: './test-loc.page.html',
  styleUrls: ['./test-loc.page.scss'],
})
export class TestLocPage implements OnInit {
  constructor(private geolocation: Geolocation) {}

  ngOnInit() {
    this.geogeo();
  }

  lat: any;
  lng: any;

  geogeo() {
    this.geolocation
      .getCurrentPosition()
      .then((resp) => {
        console.log(resp.coords.latitude);
        console.log(resp.coords.longitude);
        this.lat = resp.coords.latitude;
        this.lng = resp.coords.longitude;
      })
      .catch((error) => {
        console.log('error');
      });
  }
}

Hi, mhartington, i need your help ?

Try something like this…

  ngOnInit() {
   return this.geogeo();
  }

 geogeo() {
    return this.geolocation
      .getCurrentPosition()
....

You basically are not unwrapping the promise correctly which could lead to various issues.

Ok, thank you very much.