Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax https call in ios using PhoneGap not working?

I could not able to do https POST call using ajax from ipad/iphone. Actually I am trying to call this in my PhoneGap application.

Could you please help me in this regard.

like image 893
Easwaramoorthy K Avatar asked Feb 14 '12 12:02

Easwaramoorthy K


3 Answers

Did you try to add this at the end of you AppDelegate.m file

@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
    return YES; 
}
@end
like image 129
Titouan de Bailleul Avatar answered Nov 16 '22 18:11

Titouan de Bailleul


You have not stated the kind of certificate on the server. I suspect that it is self signed. I have also had the same problem. Doing Ajax calls to a server with self signed certificated is NOT possible and this is a SDK limitation. You must write an Objective C plugin to go around this.

like image 38
jordan koskei Avatar answered Nov 16 '22 17:11

jordan koskei


TDeBailleul,

Your code seems to work for an anonymous area of the web server, but doesn't work for myself in an Authorized area (cgi.auth_user) with Basic/NTLM authorization.

PhoneGap for iOS FAQ Q. Can I do AJAX with servers that have self-signed certificates? A. No, this is a iOS SDK limitation with UIWebview. You'll have to write an Objective-C plugin.

http://wiki.phonegap.com/w/page/41631150/PhoneGap%20for%20iOS%20FAQ

like image 3
Pat Avatar answered Nov 16 '22 18:11

Pat