Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20046] Ti.Geolocation.getCurrentPosition returns success:true with no coords

GitHub Issuen/a
TypeBug
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 5.1.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterFokke Zandbergen
AssigneeUnknown
Created2015-11-23T14:27:56.000+0000
Updated2018-11-29T13:38:02.000+0000

Description

For a new training app I did:
			Ti.Geolocation.getCurrentPosition(function(e) {

				console.debug('LOCATION: ' + JSON.stringify(e));

				if (!e.success) {
					return showError(e.error || 'Could not find your location');
				}

				getWeather(e.coords);
			});
And of course in {tiapp.xml}}:
		<key>NSLocationAlwaysUsageDescription</key>
                <string>Get the weather for your location.</string>
But the response in Simulator was:
{
	"success": true,
	"code": 0,
	"source": {},
	"type": "location",
	"error": "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
}
I expected to get coords of course, but in case of an error at least success:false instead of true. *NOTE:* The [documentartion](https://appcelerator.github.io/appc-docs/latest/#!/api/LocationResults) only lists coords and provider (Android) and not success and error.

Comments

  1. Lorenzo Piccinini 2018-11-21

  2. Lorenzo Piccinini 2018-11-25

    Someone with news? I have the same problem with android! Someone can help me?
  3. Michael Gangolf 2018-11-25

    [~otto.pic] what is the content of getCurrentPosition()? Is it just Ti.Geolocation.getCurrentPosition(callback) or a you subscribing to the location event?
  4. Lorenzo Piccinini 2018-11-25

       function getCurrentPosition() {
       		Ti.Geolocation.getCurrentPosition(function(e){
       				
       				if(e.coords){
       				
       					getData({lat: e.coords.latitude, lng: e.coords.longitude});
       				
       				}else{
       					ui.alertError();
       				}
       				
       		});
       	}
       
  5. Michael Gangolf 2018-11-27

    Did you receive a location before? If you don't have a location you'll receive NULL. When I had a location outside my app (with a GPS test tool) getCurrentPosition() returns my last location. For moving coordingats Ti.Geolocation.addEventListener('location', location); of course.
  6. Lorenzo Piccinini 2018-11-29

    I have found the problem but I haven't solution. If I install the app with wifi enabled and data and gps disabled there isn't way to get location enabling data and gps too. If I install the app with data and gps enabled all work fine. I don't understand very well what's append, but how can I get location from the best source wifi, data or gps?

JSON Source