Let me preface this with I’ve been using ionic and phonegap for about 2 weeks. My issue is I can NOT figure out where the heck I’m to initialize the getlocation code.
I created a service my code (below) and I call it in my app.js on .run, it fires but I get two alerts one asking for permission from the app, and the other like this.
/var/mobile/Applications/157EB70D-4AA7-826E-690F0CBE0F/appname.app/www/index.html
can anybody help with this? I’m stuck! How do I prevent the double request. I created a service so I could call the method if user was to move locations and pull to refresh, thus only showing data relevant to their position.
My double confirmation is not solved, but I’m a bit closer, does anybody else get double confirmation?
my app.js
.run(function($ionicPlatform, myService) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
//Service for Geo-location
document.addEventListener("deviceready", myService.Geo(), false);
});
})
What is $cordovaGeolocation in your example, is that your custom service?
I have noticed when I was calling it in the controller the controller was firing first, so maybe I’ll try wrapping my platform ready inside the controller.