简体   繁体   English

Android和ios中的https提取请求阻止-React Native

[英]https fetch request blocking in android and ios - React Native

I build one mobile app using React Native, 我使用React Native构建了一个移动应用,

In that i am using one api to fetch data, initially i have one web api in http, for example like this: http://example.com it successfully fetch data in android but not in ios, 因为我使用一个api来获取数据,所以最初我在http中有一个web api,例如: http : //example.com,它在android中成功获取了数据,但在ios中却没有,

I read apple docs then i found apple needs https for production apps, 我读了苹果文档,然后发现苹果生产应用需要https,

So i decided and change my web api protocol to https like this: https://example.com , after changing my api successfully i got response in web page when i hit that url, but now when i am running my React Native application it tells me Network Request Failed 所以我决定将我的Web api协议更改为https,例如: https : //example.com ,成功更改我的api后,当我点击该URL时,我在网页中得到响应,但是现在当我运行React Native应用程序时告诉我网络请求失败

I also change my http to https in my React Native fetch request code. 我也在我的React Native获取请求代码中将http更改为https。 I dont know whats the problem is, Is this React Native issue? 我不知道问题是什么,这是React Native问题吗?

https is not enough for iOS. 对于iOS,https还不够。 Your SSL certificate should be in compliance with TSL 1.2 or major by default. 默认情况下,您的SSL证书应符合TSL 1.2或主要标准。

You can override this behavior setting the minimum supported TSL in the info.plist file as follow: 您可以覆盖此行为,如下所示,在info.plist文件中设置支持的最低TSL:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <false/>
     <key>NSExceptionDomains</key>
<dict>
    <key>example.com</key>
    <dict>
        <key>NSIncludesSubdomains</key>
        <true/>
        <key>NSExceptionRequiresForwardSecrecy</key>
        <false/>
        <key>NSExceptionMinimumTLSVersion</key>
        <string>TLSv1.0</string>
    </dict>
</dict>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 提取请求在react-native中失败,而不是android中的http - Fetch request fails in react-native for https and not http in android 仅针对Android 7.0向HTTPS服务器发出请求时,React本机fetch()失败 - React native fetch() fails when making request to a HTTPS server for only Android 7.0 React Native提取调用在iOS上有效,但不能在Android上有效 - React Native fetch call working in iOS but not Android React native fetch请求非常慢的android - React native fetch request very slow android React Native android fetch 网络请求错误 - React Native android fetch network request error 在android上反应本机获取网络请求失败 - react native Fetch Network request failed on android React Native https axios resquest 在 Android 上出现网络错误,但在 iOS 上没有 - React Native https axios resquest gets Network Error on Android but not iOS React Native HTTPS Api 调用在 IOS 中有效,但在 ZE84E30B9390CDB64DDB6DB2CZ 中无效 - React Native HTTPS Api calls works in IOS but not working in Android 网络请求失败对 https 图像上传 Android 做出本机反应 - network request failed react native on https image upload Android React Native Android - 使用 fetch() 方法出现网络请求失败错误 - React native Android - network request failed error with fetch() method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM