Comments (4)
这个不是WebView的问题,建议让你们server好好检查一下代码和配置
from jxbwkwebview.
🤔🤔🤔老哥你好,我把Safari加载相同网页的截图发给你看,就是为了说明这个网站用其他浏览器打开是正常的。。
from jxbwkwebview.
from jxbwkwebview.
嗯嗯,可以了
`- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler {
NSString *hostName = webView.URL.host;
NSString *authenticationMethod = [[challenge protectionSpace] authenticationMethod];
if ([authenticationMethod isEqualToString:NSURLAuthenticationMethodDefault]
|| [authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic]
|| [authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPDigest]) {
NSString *title = @"网页认证";
NSString *message = [NSString stringWithFormat:@"%@ 需要用户名和密码", hostName];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"用户名";
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"密码";
textField.secureTextEntry = YES;
}];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSString *userName = ((UITextField *)alertController.textFields[0]).text;
NSString *password = ((UITextField *)alertController.textFields[1]).text;
NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:userName password:password persistence:NSURLCredentialPersistenceNone];
completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
}]];
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:alertController animated:YES completion:^{}];
});
}
else if ([authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
// needs this handling on iOS 9
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
// or, see also http://qiita.com/niwatako/items/9ae602cb173625b4530a#%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E3%82%B3%E3%83%BC%E3%83%89
}
else {
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
}
}`
from jxbwkwebview.
Related Issues (20)
- webview复用之后页面会显示空白,我在viewWillAppear中调用了webview reload
- 如果在导航控制器下,不支持右滑返回,能加个属性支持右滑返回吗
- 闪退BUG HOT 1
- Demo中关于htmlString的相关代码没有
- Demo中关于htmlString的相关代码没有
- native如何调用js HOT 1
- 白名单功能可以加吗 HOT 3
- 离线包解压缩崩溃 HOT 2
- 拦截请求,有时拦截不到请求,有时可以
- JXBWebViewController 中的 cookies注册,抓包没有注册成功
- 您好,有办法拦截到wkwebview里面的资源请求并正常发送带body的post请求吗 HOT 1
- 增加缓存机制?
- 只支持JXBJSBridge调用吗?是否支持window.WebKit.call HOT 3
- targets是中文名或者HTML文件是中文名,则无法打开,用原生的wkwebview没问题 HOT 1
- 有一个SEGV_ACCERR的问题麻烦帮看下 HOT 1
- 问个问题 HOT 1
- 能否扩展注入js文件内容 HOT 1
- WKMessageHandlerHelper中的callbackWithResult方法调整 HOT 1
- 原生 -> web -> 原生 -> web 崩溃
- 使用webview复用的方式,localstorage 被清空了
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jxbwkwebview.