Problem
When attempting to use Ti.Geolocation.forwardGeocoder in iOS 9 it never completes. On iOS 8 this works just fine.
Reproduce:
1. Simply run the following code
Ti.API.error('fwdGeocode');
Ti.Geolocation.forwardGeocoder('94111', function(e) {
Ti.API.error('fwdGeocode resp');
Ti.API.error('appcel resp:' + JSON.stringify(e));
});
Expect Result:
Works well in 3.5.1 SDK, the output is:
[ERROR] : fwdGeocode resp
[ERROR] : appcel resp:{"code":0,"longitude":"-122.400399983355","latitude":"37.7973885857828","accuracy":"1","success":true}
Actual Result:
The latest beta SDK, the output is:
[ERROR] : fwdGeocode resp
The error is happening because of the iOS9 app transport security " App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.". The calling API is "http://api.appcelerator.net/p/v1/geo". Two possible ways to fix: 1. Also wildcard http:// calls on the appcelerator.com domain 2. Update the URL in
GeolocationModule.m
to https:// [~cng] [~cbarber], thoughts?First off, ATS is off by default. You have to opt-in by manually adding the
NSAppTransportSecurity
to the Info.plist/tiapp.xml. If they opt-in, then we whitelist all appcelerator.com subdomains. However, I noticed that we defaultNSExceptionAllowsInsecureHTTPLoads
to false. I sorta think we should leave it false as we should never connect to a non-ssl appcelerator.com site. But if someone had a webview and went to appcelerator.com over http, it would fail, so I could be convinced that it should be true by default. Either way, we should definitely update GeolocationModule.m to use https. Perhaps grep the code for any other requests like this.Fixed it for iOS9, but neither
forwardGeocoder
norreverseGeocoder
are currently working, since the success delegateonLoad
is not called any more. It seems to be a problem with the latest commits made on theAPSHTTPClient
. Will hold this until [~cng] is back.PR of [~cng] (https://github.com/appcelerator/titanium_mobile/pull/7114) tested & merged. Thank you! [~sliang] can you confirm using the latest master?
backport PR: https://github.com/appcelerator/titanium_mobile/pull/7115
Ok, Confirmed. Waiting for customer's verify.
Verified as fixed, ran the code from step 1. and built to device, received following:
OSX El Capitan 10.11 iOS 9 Studio: 4.3.1.201509302304 Ti SDK: 5.0.2.GA Appc NPM: 4.2.0 Appc CLI: 5.0.2