ฉันมี UIWebView
ไปที่ไซต์ที่มีปุ่มเข้าสู่ระบบ เมื่อกดปุ่มเข้าสู่ระบบ (เช่นใน Safari) ระบบจะแจ้งให้เข้าสู่ระบบ จากนั้นจะเรียกบริการเว็บที่ตรวจสอบสิทธิ์ผ่าน AD และเข้าสู่ระบบผู้ใช้ ฉันกำลังพยายามทำให้สิ่งนี้ทำงานใน UIWebView
ของฉัน แต่ didReceiveAuthenticationChallenge
ไม่เคยถูกเรียก มีความคิดอะไรบ้าง?
- (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;
}
มีวิธีการเรียกเมธอด didReceiveAuthenticationChallenge
ด้วยตนเองหรือไม่