Commit 04073955 authored by DavidHuang's avatar DavidHuang

处理 wkwebview 内部跳转的问题

parent d7625505
......@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 70;
objectVersion = 77;
objects = {
/* Begin PBXBuildFile section */
......@@ -2645,7 +2645,7 @@
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
043F0ED92E02A60C003354EB /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
043F0ED92E02A60C003354EB /* Exceptions for "yinheReplayExt" folder in "yinheReplayExt" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Info.plist,
......@@ -2655,7 +2655,18 @@
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
043F0ECD2E02A60C003354EB /* yinheReplayExt */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (043F0ED92E02A60C003354EB /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = yinheReplayExt; sourceTree = "<group>"; };
043F0ECD2E02A60C003354EB /* yinheReplayExt */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
043F0ED92E02A60C003354EB /* Exceptions for "yinheReplayExt" folder in "yinheReplayExt" target */,
);
explicitFileTypes = {
};
explicitFolders = (
);
path = yinheReplayExt;
sourceTree = "<group>";
};
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -7238,14 +7249,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-frameworks.sh\"\n";
......@@ -7259,14 +7266,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-resources-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-resources-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-galaxy/Pods-galaxy-resources.sh\"\n";
......
......@@ -74,6 +74,7 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
askForAppToLaunch = "Yes"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
......
......@@ -11,6 +11,7 @@ import UIKit
import dsBridge
import Photos
import Kingfisher
import SafariServices
/*
快速测评 及 其他与H5交互的界面
......@@ -547,6 +548,77 @@ extension YHH5WebViewVC {
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
printLog("\(error.localizedDescription)")
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
// WKWebView intercepts the redirection by default. Enable the redirection in the following ways.
// Operations such as opening Safari
printLog("navigationAction.request.url = ")
printLog(navigationAction.request.url)
guard let url = navigationAction.request.url else {
decisionHandler(.cancel)
printLog("decisionHandler(.cancel)")
return
}
let absoluteString = url.absoluteString
printLog("navigationAction.request.URL.absoluteString=====> \(absoluteString)")
if absoluteString == "about:blank" {
decisionHandler(.cancel)
return
}
if !(absoluteString.hasPrefix("https://") || absoluteString.hasPrefix("http://")) {
if absoluteString.hasPrefix("alipayconnect://") || absoluteString.hasPrefix("alipayhk://") {
self.openApp(with: url)
decisionHandler(.allow)
return
} else if absoluteString.hasPrefix("alipay://") {
self.openApp(with: url)
decisionHandler(.allow) //fort test hjl 需要测试
return
}
}
decisionHandler(.allow)
}
// 辅助方法 - 显示消息
private func showMessage(_ message: String) {
// 替换原来的 MBProgressHUD
// 这里可以使用你偏好的提示框方案,比如:
// 方案1: 使用系统 Alert
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
present(alert, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
alert.dismiss(animated: true)
}
// 方案2: 如果使用 MBProgressHUD
// MBProgressHUD.showAdded(to: self.view, animated: true)
// let hud = MBProgressHUD.showAdded(to: self.view, animated: true)
// hud.mode = .text
// hud.label.text = message
// hud.hide(animated: true, afterDelay: 2.0)
}
// 辅助方法 - 打开应用
private func openApp(with url: URL?) {
guard let url = url else { return }
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
//
// if let tmpUrl = URL(string: "https://global.alipay.com/281002040090chyp7RdGg5AHvg49BXCv4Igh&pspName=ALIPAY_CN") {
let safariViewController = SFSafariViewController(url: url)
safariViewController.dismissButtonStyle = .close
safariViewController.modalPresentationStyle = .fullScreen
UIViewController.current?.present(safariViewController, animated: true, completion: nil)
// }
}
}
}
// MARK: - h5实现的接口
......
......@@ -7,6 +7,7 @@
//
import UIKit
import SafariServices
enum YHFunctionGroupType: Int {
case none = 0
......@@ -302,6 +303,10 @@ class YHMyNewViewController: YHBaseViewController {
if !checkLogin() { return }
let vc = YHMySettingViewController()
self.navigationController?.pushViewController(vc)
// let vc = YHH5WebViewVC()
// vc.url = "http://192.168.34.113:10301/superAppBridge.html#/order/antom-pay?id=1864&param=eyJhbGbolyFeciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTc0NzI5MzAsImkiOjQyMzgxNzEzODcwNzAyMSwidSI6IumTtuays-mbhuWboiIsInIiOiJzdXBlcl9hcHAifQ.Phsg13OfN5XJ0cLe759U2W0hH1iTZeneimgTlnouPcg"
// self.navigationController?.pushViewController(vc)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment