IOS9 微信支付报 prepayid 获取失败 ErrorDomainSSL, -9802

微信支付或访问一些网站时报错:ios

SDKSample[669:19724] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)web

缘由是 :微信

IOS9 中将 http 请求改为了 HTTPS(加密) 的方式
session

解决:
app

在项目的info.plist 文件里加上以下节点:less

技术分享

NSAppTransportSecurity - NSAllowsArbitraryLoadsdom

这个子节点的意思是:是否容许任性的加载? 设为 YES 的话就将禁用了 AppTransportSecurity 转而使用用户自定义的设置。ide

当 APP 内发起 webView 加载 https 的网页,则须要在 info.plist 中配置以下,若是网站引用的比较多应该是须要针对每一个网站进行配置。微信支付

技术分享

参考:网站

iOS 9 and OSX 10.11 require TLSv1.2 SSL for all hosts you plan to request data from unless you specify exception domains in your app's Info.plist file.

The syntax for the Info.plist configuration looks like this:

<key>NSAppTransportSecurity</key>
<dict>
 <key>NSExceptionDomains</key>
 <dict>
   <key>yourserver.com</key>
   <dict>
     <!--Include to allow subdomains-->
     <key>NSIncludesSubdomains</key>
     <true/>
     <!--Include to allow insecure HTTP requests-->
     <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
     <true/>
     <!--Include to specify minimum TLS version-->
     <key>NSTemporaryExceptionMinimumTLSVersion</key>
     <string>TLSv1.1</string>
   </dict>
 </dict>
</dict>

If your application (a third-party web browser, for instance) needs to connect to arbitrary hosts, you can configure it like this:

<key>NSAppTransportSecurity</key>
<dict>
   <!--Connect to anything (this is probably BAD)-->
   <key>NSAllowsArbitraryLoads</key>
   <true/>
</dict>

If you're having to do this, it's probably best to update your servers to use TLSv1.2 and SSL, if they're not already doing so. This should be considered a temporary workaround.

//[WXApi sendReq:req] 不跳转微信支付

能够尝试用 [WXApi safeSendReq:req]; 跳转微信支付,致使不跳转的缘由多是由于项目开发过程当中,以前应用了微信的shareSDK(没有支付功能),如今和微信支付的SDK冲突了。

解决:能够删除原来的 shareSDK 从新引入 支付的SDK。

//onResp:(BaseResp*)resp 不执行

缘由:微信支付的SDK没有代理,因此,你想获取支付后的结果的返回信息,须要去 AppDelegate 里,添加以下代码,添加微信的代理:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{   

 return  [WXApi handleOpenURL:url delegate:self];

//或者把回调方法写到其余单独的类里面 

// WXPay *wxpay=[[WXPay alloc]init];

//    return  [WXApi handleOpenURL:url delegate:wxpay];  

}

而后,再实现这个方法:

-(void) onResp:(BaseResp*)resp


ps:

http://stackoverflow.com/questions/30739473/nsurlsession-nsurlconnection-http-load-failed-on-ios-9

相关文章
相关标签/搜索