Saya mendapat UIWebView
mengunjungi situs yang memiliki tombol masuk. Setelah tombol login ditekan (misalnya di Safari), ia meminta login, lalu memanggil layanan web yang mengautentikasi melalui AD dan mencatat pengguna. Saya mencoba membuat ini berfungsi di UIWebView
saya, tetapi didReceiveAuthenticationChallenge
tidak pernah dipanggil. Ada ide?
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
{
NSLog(@"Authed = %d", _authed);
NSLog(@"Did start loading: %@ auth:%d", [[request URL] absoluteString], _authed);
NSString *theURL = [[request URL] absoluteString];
currentURL = [[request URL] absoluteString];
if (!_authed) {
_authed = NO;
[[NSURLConnection alloc] initWithRequest:request delegate:self];
NSLog(@"shouldStartLoadWithRequest Return NO");
return NO;
}
NSLog(@"shouldStartLoadWithRequest Return YES");
return YES;
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
{
NSLog(@"got auth challange");
NSLog(@"previousFailureCount = %d", [challenge previousFailureCount]);
ch = challenge;
[[challenge sender] useCredential:[NSURLCredential credentialWithUser:@"myusername" password:@"mypassword" persistence:NSURLCredentialPersistencePermanent] forAuthenticationChallenge:challenge];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
{
NSLog(@"received response via nsurlconnection");
_authed = YES;
NSString *urladdress = currentURL;
NSURL *url = [NSURL URLWithString:urladdress];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[itemWebView loadRequest:urlRequest];
}
- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection;
{
return NO;
}
Apakah ada cara untuk memanggil metode didReceiveAuthenticationChallenge
secara manual?