转载自:https://blog.csdn.net/fxp850899969/article/details/56485447

IOS上:

在appDelegate.m文件中添加以下代码:

@implementation NSURLRequest(DataController)

+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host

{

return YES;

}

@end

Android上:

修改 org.apache.cordova.engine.SystemWebViewClient.java文件中onReceivedSslError()方法为如下:

/**

* Notify the host application that an SSL error occurred while loading a resource.

* The host application must call either handler.cancel() or handler.proceed().

* Note that the decision may be retained for use in response to future SSL errors.

* The default behavior is to cancel the load.

*

* @param view The WebView that is initiating the callback.

* @param handler An SslErrorHandler object that will handle the user's response.

* @param error The SSL error object.

*/

@TargetApi(8)

@Override

public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

handler.proceed();

}

更多推荐