在android 4.4下的webview中使用重定向时获取不安全内容

在android 4.4下的webview中使用重定向时获取不安全内容,android,webview,android-4.3-jelly-bean,Android,Webview,Android 4.3 Jelly Bean,我们有一个应用程序,其中我们在webview中使用iFrames进行一些重定向。此重定向发生在使用自定义协议的HTTPS页面上(例如:customProtocol://) 然后在shouldOverrideUrlLoading中拦截此重定向以执行我们的逻辑 重定向在kitkat及以上版本中工作,该版本具有基于铬的网络视图,但在android 4.4以下的手机/平板电脑上,我们从**错误**中获得**显示的不安全内容的页面,该页面被阻止,并且不调用shouldOverrideAllowing 是否

我们有一个应用程序,其中我们在webview中使用iFrames进行一些重定向。此重定向发生在使用自定义协议的HTTPS页面上(例如:customProtocol://)

然后在
shouldOverrideUrlLoading
中拦截此重定向以执行我们的逻辑

重定向在kitkat及以上版本中工作,该版本具有基于铬的网络视图,但在android 4.4以下的手机/平板电脑上,我们从**错误**中获得**显示的不安全内容的页面,该页面被阻止,并且不调用
shouldOverrideAllowing


是否有任何方法允许4.4以下的webview允许https页面中的自定义协议

我不确定,试试这个

直接链接到移动设备的自定义协议处理程序


应用程序重定向
(功能(){
//对于桌面浏览器,请记住传递链接上的所有元数据以进行深度链接
var fallbackLinkhttp://example.com/my-web-app/'+window.location.search+window.location.hash;
//简单设备检测
var isiOS=navigator.userAgent.match('iPad')| | navigator.userAgent.match('iPhone')| | navigator.userAgent.match('iPod'),
isAndroid=navigator.userAgent.match('Android');
//流动的
if(isiOS | | isAndroid){
//在iframe中加载我们的自定义协议,对于Chrome和Opera,这将隐藏错误对话框(实际上是HTML)
//对于iOS,如果此协议不受支持,我们将得到一个弹出错误,但它不会阻止javascript
document.getElementById('loader').src='custom-protocol://my-app'+window.location.search+window.location.hash;
//Android的备用链接必须是https://而不是market://否则设备将尝试
//加载两个URL,只有最后一个会赢。(特别是FireFox,其中会出现“你确定”对话框)
//在iOS上,我们可以直接链接到应用商店,因为我们的应用程序交换机将在切换之前启动
//如果你有一个移动web应用程序,你的后备方案可能是这样。
fallbackLink=isAndroid?“https://play.google.com/store/apps/details?id=com.mycompany.myapp' :
“itms-apps://itunes.apple.com/app/my-app/idxxxxxxxx?mt=8' ;
}
//现在,如果用户被重定向到您的自定义应用程序,我们只需等待一切执行
//如果没有自定义应用程序(或用户在桌面上),则不会触发下面的超时
//我们将用回退链接(商店URL或桌面URL,视情况而定)替换当前URL
setTimeout(函数(){window.location.replace(fallbackLink);},1);
/*
问答
我也有一个本机桌面应用程序,如何链接到桌面上的自定义协议处理程序?
仅IE:http://msdn.microsoft.com/en-us/library/ms537512.aspx#Version_Vectors
所有其他浏览器:像iTunes一样使用自定义插件:http://ax.itunes.apple.com/detection/itmsCheck.js
*/
})();
参考: 永远地

链接

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>

<!-- iframe used for attempting to load a custom protocol -->
<iframe style="display:none" height="0" width="0" id="loader"></iframe>

<script>(function(){
// For desktop browser, remember to pass though any metadata on the link for deep linking
var fallbackLink = 'http://example.com/my-web-app/'+window.location.search+window.location.hash;
// Simple device detection
var isiOS = navigator.userAgent.match('iPad') || navigator.userAgent.match('iPhone') || navigator.userAgent.match('iPod'),
isAndroid = navigator.userAgent.match('Android');
// Mobile
if (isiOS || isAndroid) {
// Load our custom protocol in the iframe, for Chrome and Opera this burys the error dialog (which is actually HTML)
// for iOS we will get a popup error if this protocol is not supported, but it won't block javascript
document.getElementById('loader').src = 'custom-protocol://my-app'+window.location.search+window.location.hash;
// The fallback link for Android needs to be https:// rather than market:// or the device will try to
// load both URLs and only the last one will win. (Especially FireFox, where an "Are You Sure" dialog will appear)
// on iOS we can link directly to the App Store as our app switch will fire prior to the switch
// If you have a mobile web app, your fallback could be that instead.
fallbackLink = isAndroid ? 'https://play.google.com/store/apps/details?id=com.mycompany.myapp' :
'itms-apps://itunes.apple.com/app/my-app/idxxxxxxxx?mt=8' ;
}
// Now we just wait for everything to execute, if the user is redirected to your custom app
// the timeout below will never fire, if a custom app is not present (or the user is on the Desktop)
// we will replace the current URL with the fallbackLink (store URL or desktop URL as appropriate)
window.setTimeout(function (){ window.location.replace(fallbackLink); }, 1);
/*
Q&A
I have a native desktop app as well, how do I link to a custom protocol handler on the desktop?
IE Only: http://msdn.microsoft.com/en-us/library/ms537512.aspx#Version_Vectors
All Other Browsers: Use a custom plugin like iTunes does: http://ax.itunes.apple.com/detection/itmsCheck.js
*/
})();</script>
</body>
</html>