iOS LocationManager is not updating location (Tita

2020-05-08 18:32发布

问题:

I've made Appcelerator Titanium Module for fetching device's rotaion and location. Source can be found on GitHub.

The problem is that it fetches only one cached location but device motion data is OK and it is refreshing.

I don't use delegate, I pull that data in my Titanium Javascript Code. If I set "City Run" in Simulator -> Debug -> Location nothing happens. The same cached location is returning.

Pulling of location is OK because I tried with native app wich does this:

textView.text = [NSString stringWithFormat:@"%f %f\n%@",
                     locationManager.location.coordinate.longitude,
                     locationManager.location.coordinate.latitude,
                     textView.text];

And it is working in simulator and on device.

But the same code as you can see on GitHub is not working as Titanium module.

Any ideas?

EDIT:

I am looking at GeolocationModule src and I see nothing special there.

As I said, my code in my module has to work since it is working in native app. "Only" problem is that it is not updating location and it always returns me that cached location.

回答1:

The answer is to put ENSURE_UI_THREAD at the top of function that starts location updating.