Reputation: 161
I was trying to make an ajax call with basic authentication on a hybrid mobile ios application. The ajax call returns nothing it just hangs no success nor failure. But the same ajax call fires successfully from android.
While i was checking the outgoing request with wireshark i found that the authentication header is missing and a 401 is returning from my server and on subsequent call the authentication header is also send along with the request which returns a 301. But it works with android
The same api was working fine from my dev server in ios but fails in my prod server
Any Suggestions is appreciated
Upvotes: 4
Views: 1272
Reputation: 1029
This seems to be resolved with Cordova iOS platform 4.X and later. I just updated an older app from using UIWebView to WKWebView and this problem no longer occurs and we could removed the relatively painful workaround (using synchronous calls).
Upvotes: 0
Reputation: 695
I'm using cordova 4.2.0.
I have observed that in case of a 401 response with the "WWW-Authenticate: Basic" header, IOS/UIWebView seems to swallow the response instead of passing it back to the application layer, which gives the effect of the service never responding. Perhaps this is to prevent authentication popups.
In any event the behavior is completely unexpected!
edit: I found a cordova bug report for this problem: https://issues.apache.org/jira/browse/CB-2415
Upvotes: 2