I have a Titanium Android app that I’m developing and recently deployed to the Google Play store. The app works just fine when I install it directly on the device from the Titanium Studio workspace; however, when I try to install it from the Google Play store it does not work. The “does not work” feature in question here is a call to an https web service to authenticate a user. Also, I’ve noticed that ICS users are able to get the app to work from the Play store, whereas Gingerbread users are not if that’s helpful.
This is the code that causes a problem:
var actInd=Titanium.UI.createActivityIndicator({height:80, width:200, message:'Logging In...', font:{fontFamily:'Helvetica Neue', fontSize:18,fontWeight:'bold'}, color:'white', style: Titanium.UI.iPhone.ActivityIndicatorStyle.BIG});
actInd.show();
//Validating Data
var xhr2 = Titanium.Network.createHTTPClient();
xhr2.onload = function(){
var response=JSON.parse(this.responseText);
if(response.resultinfo.result){
ticket = response.resultinfo.ticket;
Titanium.App.Properties.setString("uname",username.value);
actInd.message='Successful...';
actInd.show();
}
};
xhr2.onerror = function(){
Ti.API.info('in utf-8 error for GET');
};
xhr2.open("GET","https://example.com/login.cfm");
xhr2.send({"userid":username.value,"password":password.value});
In the problem case the app just hangs on showing the “Logging In…” message.
Thanks to @Hydrangea I was able to isolate the problem as a certificate validation error. Apparently there is an issue with some versions of Android prior to ICS not correctly validating valid SSL certificates even though they are setup properly. There is a setting in the Titanium.Network.HTTPClient called “validatesSecureCertificate” that defaults to false for testing, but to true when an app is released for distribution. This is why the problem was occurring only on the Play store version. Setting this to false seems to solve the problem and I believe it is safe to do so at a per-call level.