react native https

1. ios解決方案

1.1 Xcode打開工程,Libraries -> RCTNetworking -> RCTHTTPRequestHandler.mm -> #pragma mark NSURLSession delegate

添加以下代碼ios

- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
}

1.2 ios 工程中 找到 info.plist

一、在Info.plist中添加 NSAppTransportSecurity 類型 Dictionary ;
二、在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 類型Boolean ,值設爲 YES;
相關文章
相關標籤/搜索