Reputation: 15558
I'm deploying my Meteor (1.2.0.2) app to an Android device.
I installed the plugin by
meteor add cordova:[email protected]
Added Cordova plugin [email protected].
I used the plugin by:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(function(p){ // onSuccess
console.log(p);
}, function(e){
console.log(e);
});
}
On desktop works perfectly (print p as Geolocation object) but on mobile it just ignores the callbacks (both success and errors).
I tested it in Chrome DevTools (chrome://inspect) by setting breakpoints. It steps until .getCurrentPosition call but then (either step over or step in) just skips both callbacks (and If I set a breakpoint within them, they are just not hit).
I even tried
navigator.geolocation.getCurrentPosition(function(p){ console.log(p);
both on Desktop console (works)
undefined
Geolocation { ... }
and mobile (does not work)
undefined
// nothing else is printed
Maybe has it something to do with app's permissions?
EDIT: I verified AndroidManifest.xml and the permissions are actually set by the plugin:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Upvotes: 0
Views: 856
Reputation:
@dragonmnl,
You did not talk about timeout, I must assume you have NOT set the timeout long enough. Try setting it to about 20 seconds -- as a minimum.
If your readings are poor, or you are timing out
In about 30-45 seconds you should have a reading. This will make sense when you read the link I gave you.
Jesse
Upvotes: 1