Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cordova 允许导航白名单未首先在“上测试”;UIWebViewNavigationTypeLinkClicked";科尔多瓦事件iOS@4.0.0_Cordova_Cordova Plugins - Fatal编程技术网

Cordova 允许导航白名单未首先在“上测试”;UIWebViewNavigationTypeLinkClicked";科尔多瓦事件iOS@4.0.0

Cordova 允许导航白名单未首先在“上测试”;UIWebViewNavigationTypeLinkClicked";科尔多瓦事件iOS@4.0.0,cordova,cordova-plugins,Cordova,Cordova Plugins,我正在创建一个示例应用程序来评估Cordovaios@4.0.0使用Cordova 5.4.1,现在遇到了一个问题 我的示例应用打算访问webview中的*,并在访问其他域时打开系统浏览器 下面是我编写的示例代码 ・index.html <html> <head> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-high

我正在创建一个示例应用程序来评估Cordovaios@4.0.0使用Cordova 5.4.1,现在遇到了一个问题

我的示例应用打算访问webview中的*,并在访问其他域时打开系统浏览器

下面是我编写的示例代码

・index.html

<html>
<head>
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
    <link rel="stylesheet" type="text/css" href="css/index.css">
    <script type="text/javascript">
 // open google on start up.
    var ref = window.open("https://www.google.co.jp", '_self', 'location=no');
    </script>
    <title>Hello World</title>
</head>
<body>
    <div class="app">
        <h1>Apache Cordova</h1>
    </div>
</body>
</html>

//在启动时打开谷歌。
var ref=窗口打开(“https://www.google.co.jp“,”自我“,”位置=否“;
你好,世界
阿帕奇科尔多瓦酒店
・config.xml

...
<access origin="*" requires-forward-secrecy="false" />
<!-- Added google.co.jp to allow open in webview -->
<allow-navigation href="https://www.google.co.jp/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
...
。。。
.
(这个代码对我来说很好用android@4.1.1.(另一方面)

我终于发现我必须破解obj-c本机代码ios@4.0.0提供

在CDVIntentAndNavigationFilter.m中,当UIWebviewNavigationTypeLinkClicked事件发生时,在允许意图白名单之后测试了允许导航白名单。 因此,我首先添加了测试允许导航白名单的代码

・CDVIntentAndNavigationFilter.m

- (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request     navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL* url = [request URL];

    switch (navigationType) {
        case UIWebViewNavigationTypeLinkClicked:
            // Note that the rejection strings will *only* print if
            // it's a link click (and url is not whitelisted by <allow-*>)

            // FIXME suppose we should test the navigation whitelist first
            // ↓↓ this code not exists in cordova iOS@4.0.0 at this moment
            if ([self.allowNavigationsWhitelist URLIsAllowed:url]) {
                // the url is in the <allow-navigation> tag, so we can navigate to this url
                return YES;
            }
            // ↑↑ this code not exists in cordova iOS@4.0.0 at this moment

            if ([self.allowIntentsWhitelist URLIsAllowed:url]) {
                // the url *is* in a <allow-intent> tag, push to the system
                [[UIApplication sharedApplication] openURL:url];
                return NO;
            }
            // fall through, to check whether you can load this in the webview
        default:
            // check whether we can internally navigate to this url
            return ([self.allowNavigationsWhitelist URLIsAllowed:url]);
    }
-(BOOL)应重写AdWithRequest:(NSURLRequest*)请求导航类型:(UIWebViewNavigationType)导航类型
{
NSURL*url=[请求url];
开关(导航类型){
案例UIWebViewNavigationTypeLinkClicked:
//请注意,拒绝字符串将*仅*在以下情况下打印:
//这是一个链接点击(并且url不会被列入白名单)
//修正我假设我们应该首先测试导航白名单
// ↓↓ 此代码在cordova中不存在iOS@4.0.0此时此刻
如果([self.allowNavigationsWhitelist url被允许:url]){
//url位于标记中,因此我们可以导航到此url
返回YES;
}
// ↑↑ 此代码在cordova中不存在iOS@4.0.0此时此刻
if([self.allowinentswhitelist url被允许:url]){
//url*在标记中,推送到系统
[[UIApplication sharedApplication]openURL:url];
返回否;
}
//下载,以检查是否可以在webview中加载此内容
违约:
//检查是否可以在内部导航到此url
返回([self.allowNavigationsWhitelist url被允许:url]);
}
我不确定这个问题是否是一个bug。如果是,我将尝试向社区报告一个问题,如果不是,是否有任何解决方法来避免这个问题而不破坏Cordova提供的黑客框架