Unable to connect react native app to backend on iOS 15

Viewed 325

My react-native app is not able to connect to the backend on iOS 15 devices only. Devices with iOS less than 15 and android devices are working fine.

I am using http connection with a static IP address. I cannot switch to https now, neither can I use a domain name instead of an IP address. And I also cannot add the static IP to the exception domains since that is not accepted.

I have the following code in my Info.plist file:

<dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>

Is there a way to fix this without using a domain name or switching to HTTPS?

1 Answers

I managed to solve this, in case anyone came across this thread. Weirdly, adding

'Accept-Language': 'en'

to the header when making the API calls solved this issue!

It is only happening on iOS 15 devices, so I don't know the reason, but it turned out to not be related to the HTTP connection.

Related