Node.js 未在Next.js Firebase宿主网站上调用WKWebView WKNavigationDelegate
我正在使用下面的WKNavigationDelegate方法来监视当前url,以便在用户点击某个url时将WKWebView从堆栈中弹出Node.js 未在Next.js Firebase宿主网站上调用WKWebView WKNavigationDelegate,node.js,next.js,wkwebview,firebase-hosting,Node.js,Next.js,Wkwebview,Firebase Hosting,我正在使用下面的WKNavigationDelegate方法来监视当前url,以便在用户点击某个url时将WKWebView从堆栈中弹出 func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { print("
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
print("DELEGATE CALLED")
guard let url = navigationAction.request.url else {
print("GUARD CALLED FOR .allow")
decisionHandler(.allow)
return
}
print(url)
if url.absoluteString.contains("/about") {
print("IF CALLED FOR .cancel")
decisionHandler(.cancel)
parent.showingWebViewTest = false
} else {
print("ELSE CALLED FOR .allow")
decisionHandler(.allow)
}
}
当我对不属于我的项目的url使用此方法时。它似乎工作得很好。下面是点击基本url和我正在监控的url时的打印输出。点击受监控的url时,WKWebView会按预期弹出
基本URL
DELEGATE CALLED https://www.flocycling.com/ ELSE CALLED FOR .allow
DELEGATE CALLED https://www.flocycling.com/ ELSE CALLED FOR .allow
DELEGATE CALLED https://flocycling.com/ ELSE CALLED FOR .allow
DELEGATE CALLED
https://flocycling.com/pages/about
IF CALLED FOR .cancel
2021-04-16 13:03:12.310439-0700 Global Seafood Exchange[79393:6686501] WF: _userSettingsForUser : (null)
2021-04-16 13:03:12.310584-0700 Global Seafood Exchange[79393:6686501] WF: _WebFilterIsActive returning: NO
DELEGATE CALLED
https://www.flocycling.com/
ELSE CALLED FOR .allow
DELEGATE CALLED
https://flocycling.com/
ELSE CALLED FOR .allow
受监控的URL
DELEGATE CALLED https://www.flocycling.com/ ELSE CALLED FOR .allow
DELEGATE CALLED https://www.flocycling.com/ ELSE CALLED FOR .allow
DELEGATE CALLED https://flocycling.com/ ELSE CALLED FOR .allow
DELEGATE CALLED
https://flocycling.com/pages/about
IF CALLED FOR .cancel
2021-04-16 13:03:12.310439-0700 Global Seafood Exchange[79393:6686501] WF: _userSettingsForUser : (null)
2021-04-16 13:03:12.310584-0700 Global Seafood Exchange[79393:6686501] WF: _WebFilterIsActive returning: NO
DELEGATE CALLED
https://www.flocycling.com/
ELSE CALLED FOR .allow
DELEGATE CALLED
https://flocycling.com/
ELSE CALLED FOR .allow
但是,当我尝试在Firebase上承载的NextJS上构建的站点使用此方法时,在初始站点加载时会调用一次委托方法,然后在导航站点时不会再次调用该方法。在Firebase Hosting上托管的站点的打印输出构建在NextJS上,如下所示
DELEGATE CALLED
https://www.testsiteformyapp.com/
ELSE CALLED FOR .allow
DELEGATE CALLED
https://testsiteformyapp.com/
ELSE CALLED FOR .allow
2021-04-16 13:08:45.586447-0700 Test Site[79510:6699787] WF: _userSettingsForUser : (null)
2021-04-16 13:08:45.587173-0700 Test Site[79510:6699787] WF: _WebFilterIsActive returning: NO
2021-04-16 13:08:45.646099-0700 Test Site[79510:6699787] [Process] 0x7ffc78067220 - [pageProxyID=6, webPageID=7, PID=79515] WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = NSURLErrorDomain, code = -999
DELEGATE CALLED
https://www.testsiteformyapp.com/
ELSE CALLED FOR .allow
DELEGATE CALLED
https://testsiteformyapp.com/
ELSE CALLED FOR .allow
DELEGATE CALLED
https://testsiteformyapp.firebaseapp.com/__/auth/iframe?apiKey=*********************&appName=%5BDEFAULT%5D&v=8.2.5&usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en_US.MWM3Xj_RD9s.O%2Fam%3DAQ%2Fd%3D1%2Fct%3Dzgms%2Frs%3DAGLTcCOUmnuCcTtedasW7L1tq37fs4eoIg%2Fm%3D__features__#id=I0_1618603726774&_gfid=I0_1618603726774&parent=https%3A%2F%2Ftestsiteformyapp.com&pfname=&rpctoken=69235721
ELSE CALLED FOR .allow
2021-04-16 13:09:01.047437-0700 Test Site[79510:6701010] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
我不确定这是否与NextJS或Firebase或其他完全相关。任何帮助都将不胜感激