Ionic 3 Geolocation Not Working When Gps Is Disabled
I have ionic native geolocation plugin installed '@ionic-native/geolocation': '^4.15.0' I have also tried '4.6.0' and '4.20.0'. It is working absolutely fine when I keep my GPS e
Solution 1:
you should manually ask permission and request the user to enable location. You can do this with the Diagnostic plugin (@ionic-native/diagnostic). You should use the following methods:
diagnostic.isLocationEnabled()
diagnostic.isLocationAvailable()
diagnostic.requestLocationAuthorization()
If you want to update location after permission is granted you you can use this method:
diagnostic.registerLocationStateChangeHandler()
You can pass a callback here check if location is enabled and available de what you need.
Solution 2:
Install the Diagnostics plugin from here: https://ionicframework.com/docs/v3/native/diagnostic/, then check if location is enabled with diagnostics.isLocationAvailable()
, if not, prompt the user to enable it from the device settings screen using diagnostics.switchToLocationSettings()
.
Post a Comment for "Ionic 3 Geolocation Not Working When Gps Is Disabled"