Problem description
If you call Titanium.Geolocation.getPreferredProvider() and the Geo services are not enabled, the app will crash.
Actual results
The app crashes
Expected results
IF there is no geo services enabled, just warn the user.
Test Case.
1. Create a new mobile project.
2. Paste this code:
Ti.API.info(Titanium.Geolocation.getPreferredProvider());
3. Disable Geolocation services in the device.
4. Build for device.
5. Run the app
HD Discussion
http://support-admin.appcelerator.com/display/APP-423883
Workaround
if(Titanium.Geolocation.getLocationServicesEnabled()){
Ti.API.info(Titanium.Geolocation.getPreferredProvider());
} else {
alert('Geo Services not enabled');
Ti.API.info("Geo Services not enabled");
}
Note [preferredProvider](http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.Geolocation-property-preferredProvider) has been deprecated. The [accuracy](http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.Geolocation-property-accuracy) property is the new method for "simple mode".
Closing issue since there is a work around and the property is deprecated and will be removed.
[PR #2088](https://github.com/appcelerator/titanium_mobile/pull/2088) fixes a crash/JS error seen when trying to call getPreferredProvider(). No longer see any application crashes after applying the fix.
Titanium Studio: 2.1.0.201206221045 Mobile SDK: 2.1.0.v20120622174154 OS: X Lion Device: Samsung Galaxy Fixed. App doesn't crash, nor does it provide any string information about geo location or warning message, either with Geo-location setting is enable or disable from device settings. Returned undefined
Re-opening to edit label