zoukankan      html  css  js  c++  java
  • iOS Webview打开不受信的URL

        在我们开发过程中经常会碰到直接访问开发人员的私有地址, 这样在app 上是无法打开指定的网页的。

       在iOS中需要对WKWebView 进行如下设置:

    1、在工程的Plist 文件中添加一下选项

       App Transport Security Settings -> Allow Arbitrary Loads in Web Content  设置为YES ,如下图

    2、 WKWebView 指定的代理类中,实现协议WKNavigationDelegate

    - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler{
    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
    NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
    completionHandler(NSURLSessionAuthChallengeUseCredential,card);
    }
    }

      通过以上方法本人已经验证可以跳转私有IP地址Web。

  • 相关阅读:
    android实现计时器(转)
    单例模式和静态类
    ADC电阻分压采集相关知识
    什么是中断?
    什么是时钟芯片 ?
    单片机与PLC的区别?
    FreeRTOS常用函数
    ADC采集电流相关知识
    CA和SSL证书介绍
    物联网设备的安全性预防(转)
  • 原文地址:https://www.cnblogs.com/kingbo/p/8576134.html
Copyright © 2011-2022 走看看