This commit is contained in:
liyuhua
2023-11-23 18:23:09 +08:00
parent 05e0da7740
commit 6f4610044d
2 changed files with 27 additions and 7 deletions

View File

@@ -156,4 +156,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: cc88fa05da662ee682fc0eeb502faab221faa032
COCOAPODS: 1.14.2
COCOAPODS: 1.12.1

View File

@@ -98,7 +98,29 @@ NSString * const kJSGetUid = @"getUid";
}
}];
}
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler{
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
dispatch_async(dispatch_get_main_queue(), ^{
NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
completionHandler(NSURLSessionAuthChallengeUseCredential,card);
});
}
}
//
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
//progressView
self.progressView.hidden = YES;
}
//
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
//progressView
self.progressView.hidden = YES;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
if ([keyPath isEqualToString:@"estimatedProgress"]) {
self.progressView.progress = self.webview.estimatedProgress;
@@ -155,21 +177,19 @@ NSString * const kJSGetUid = @"getUid";
if (![_url hasPrefix:@"http"] && ![_url hasPrefix:@"https"]){
_url = [NSString stringWithFormat:@"%@/%@", API_HOST_H5_URL, _url];
}
if (![_url containsString:@"alipayh5"]) {
if (![_url containsString:@"?"]) {
_url = [NSString stringWithFormat:@"%@?platform=%@", _url, [YYUtility appName]];
} else {
_url = [NSString stringWithFormat:@"%@&platform=%@", _url, [YYUtility appName]];
}
}
// urlString
NSString *noSpaceTextUrl = [_url stringByReplacingOccurrencesOfString:@" " withString:@""];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:noSpaceTextUrl]];
if ([_url containsString:@"wx.tenpay"]) {
[request setValue:[NSString stringWithFormat:@"xdx.%@://", CompanyFirstDomainByWeChatRegister] forHTTPHeaderField:@"Referer"];
}
[self.webview loadRequest:request];
}