我有一個網址domain.com/map.jsp這是一個JSP頁面,它顯示了帶有自定義標記的谷歌地圖,用於編寫一些javascript代碼。當我在設備上加載此頁面時,它顯示我錯誤爲NSURLSession/NSURLConnection HTTP加載失敗(kCFStreamErrorDomainSSL,-9814)。但它在iOS模擬器上正常工作。加載webview中的NSURLSession/NSURLConnection HTTP加載失敗(kCFStreamErrorDomainSSL,-9814)?
我在谷歌上搜索了很多關於這方面的信息,但沒有解決方案。
1.Bye網址傳遞
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
2.Specifying網址only.I不能硬編碼的網址,因爲URL可以是動態的,所以下面的代碼不會爲我工作。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourdomain.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
3.我已經添加下面mywebview類的方法,但沒有一種方法被調用
-(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:
(NSURLProtectionSpace *)protectionSpace {
return YES;
}
-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:
(NSURLAuthenticationChallenge *)challenge {
if (([challenge.protectionSpace.authenticationMethod
isEqualToString:NSURLAuthenticationMethodServerTrust])) {
if ([challenge.protectionSpace.host isEqualToString:@"mydomain.com"]) {
NSLog(@"Allowing bypass...");
NSURLCredential *credential = [NSURLCredential credentialForTrust:
challenge.protectionSpace.serverTrust];
[challenge.sender useCredential:credential
forAuthenticationChallenge:challenge];
}
}
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
請說明爲什麼它不工作的iOS設備上,但它是在simulator.What工作的罰款解決方案?
請參閱http://stackoverflow.com/questions/33127376/ios9-http-connection-error –
應用程序傳輸安全性也不起作用嗎?甚至不允許任意加載?這很奇怪...你確定你把它輸入了正確的plist文件嗎?關於委託方法:您確實將webView的代理設置爲您的視圖控制器,對吧? – Gero
對所有其他網址的工作正常awsome.but僅適用於谷歌地圖文件它創造的問題 – Techiee