2

I am trying to access a secure for local network url through UIWebView. When I access it through safari, i get an authentication challenge but the same does not appear in my UIWebView in the application. How can I make it appear?

E.g. http://292.168.1.54/TestWeb/Test.pdf

This url working in safari browser but the same url does not appear in my UIWebView.

Any pointers, sample code or links will be very helpful. Thanks a lot.

Chetan Mahajan
  • 388
  • 2
  • 15

2 Answers2

1

There are two ways to get to the authentication (in your case probably basic auth) challenge.

  1. -[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] will give you the request. Now you just start a second request to the same URL and use [NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge:] to get the challenge. Then you present a dialog and ask the user for credentials. Save the credentials in NSURLCredentialStorage and then reload the page.

  2. Create a subclass of NSURLProtocol that handles http and https. Similar to this answer and get the authentication challenge there.

Community
  • 1
  • 1
orkoden
  • 18,946
  • 4
  • 59
  • 50
0

I hope this code will help you.

  • (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. self.webView.delegate = self;

        NSURL *url = [NSURL URLWithString:@"http://skinC.com/abc/"];// here you can write your url that you want to open
        NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
        [self.webView loadRequest:requestURL];
    
          AppDelegate *appDel = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
    
        [self setNeedsStatusBarAppearanceUpdate];}