Problem
Ti.Geolocation.getCurrentPosition() method does not work in conjunction with a Ti.Geolocation.addEventListener('location', ...), the getCurrentPosition callback event is never called.
Tested on
iOS simulator 5.1 & iphone 4
Steps to reproduce
1. run the code. No pause/resume events needed.
2. From a fresh launch, the button will do nothing if line 40 is uncommented.
Repro sequence
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
var win = Titanium.UI.createWindow({
title: 'test'
});
Ti.Geolocation.trackSignificantLocationChange = true;
Titanium.Geolocation.distanceFilter = 10;
Titanium.Geolocation.purpose = "Testing";
var n=0, notification = [];
var locationCallback = function(e){
var longitude = e.coords.longitude;
var latitude = e.coords.latitude;
notification[n] = Titanium.App.iOS.scheduleLocalNotification({
alertBody: 'long: ' + longitude + '\nlat: ' + latitude,
alertAction:"View App",
userInfo:{"hello":"world"},
date: new Date()
});
//alert(e)
n++;
};
var btn = Ti.UI.createButton({
title: 'Get Location',
width: Ti.UI.SIZE,
height: Ti.UI.SIZE
});
win.add(btn);
btn.addEventListener('click', function(){
Ti.Geolocation.getCurrentPosition(function(e){
alert(e.coords);
});
})
//Ti.Geolocation.addEventListener('location', locationCallback);
win.open();
PR https://github.com/appcelerator/titanium_mobile/pull/3041
CR & FR
Tested with 3.0.0.v20121130200208 on iPhone 4 5.1.1