I am creating a mobile app using node, angular, ionic and cordova, which should be compatible with android version 4.0.3 and higher. I want the app to pop up a notification if GPS is disabled by the user. And also the notification should have options to cancel and direct to GPS settings for the user to switch GPS on manually.
To do this I tried following npm plugins, but none of them worked for me. When I tried them, only the splashscreen showed up and nothing else.
- cordova.plugins.diagnostic
- cordova-plugin-fastrde-checkgps
- cordova-plugin-android-gpsdetect
This is the code I tried using cordova.plugins.diagnostic plugin.
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
cordova.plugins.diagnostic.isGpsLocationEnabled(function(enabled){
alert("GPS location is " + (enabled ? "enabled" : "disabled"));
}, function(error){
alert("error");
});
})
What am I doing wrong here? I followed this in my code. Can someone please tell me how to get this done?