Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebview won't load dynamically loaded resources (via jQuery mobile) over basic authentication

Bit of a confusing one and not sure where the solution (or problem) originates.

I am creating an iPad app using UIWebviews and Jquery Mobile. I am having to access my web resource over basic authentication. I have set up the UIWebview to correctly send my login credentials through the HTTP request and all the resources and those required by the page (CSS, Javascript etc) are loading correctly....

...except for those resources that are loaded dynamically via Javascript.

I am using Modernizr to load CSS files and JQuery to load a .JSON file and none of these are loaded when accessing my page via the webView. (when I access the page directly via Safari it works fine).

I am guessing therefore its an Xcode / iOS issue but I'm not sure where to start.

Any help / pointers would be great!

like image 684
user1654248 Avatar asked Sep 07 '12 09:09

user1654248


1 Answers

Answer can be found here: How to do authentication in UIWebView properly?

Quoting solution:

    NSString* login = @"MYDOMAIN\\myname";
    NSURLCredential *credential = [NSURLCredential credentialWithUser:login
                                                             password:@"mypassword"
                                                          persistence:NSURLCredentialPersistenceForSession];

    NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc]
                                             initWithHost:@"myhost"
                                             port:80
                                             protocol:@"http"
                                             realm:@"myhost" // check your web site settigns or log messages of didReceiveAuthenticationChallenge
                                             authenticationMethod:NSURLAuthenticationMethodDefault];


    [[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential forProtectionSpace:protectionSpace];
    [protectionSpace release];    
like image 128
sqreept Avatar answered Oct 21 '22 03:10

sqreept