Sameer
Sameer

Reputation: 3496

https fetch request blocking in android and ios - React Native

I build one mobile app using 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,

I read apple docs then i found apple needs https for production apps,

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

I also change my http to https in my React Native fetch request code. I dont know whats the problem is, Is this React Native issue?

Upvotes: 0

Views: 2730

Answers (1)

Joe Aspara
Joe Aspara

Reputation: 1197

https is not enough for iOS. Your SSL certificate should be in compliance with TSL 1.2 or major by default.

You can override this behavior setting the minimum supported TSL in the info.plist file as follow:

<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>

Upvotes: 2

Related Questions