Chuuubs
Chuuubs

Reputation: 11

Possible unhandled promise rejection (id: 0)

I've been having this problem for over a month now, this error occurs whenever I try to login to my react-native app using a mobile device.

This is the error enter image description here

And this is the code to login in my react native app enter image description here

Upvotes: 1

Views: 2728

Answers (2)

Someone Special
Someone Special

Reputation: 13588

There's this part of the docs you need to take note of. What you are missing is adding an App Transport Security exception, since you are not using localhost as server, and https is required.

By default, iOS will block any request that's not encrypted using SSL. If you need to fetch from a cleartext URL (one that begins with http) you will first need to add an App Transport Security exception. If you know ahead of time what domains you will need access to, it is more secure to add exceptions only for those domains; if the domains are not known until runtime you can disable ATS completely. Note however that from January 2017, Apple's App Store review will require reasonable justification for disabling ATS. See Apple's documentation for more information.

An example of ATS is as follows, in info.plist

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <false/>
  <key>NSExceptionDomains</key>
  <dict>
    <key>example.com</key>
    <dict>
      <key>NSIncludesSubdomains</key>
      <true/>
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
    </dict>
  </dict>
</dict>

For android, similarly from docs

On Android, as of API Level 28, clear text traffic is also blocked by default. This behaviour can be overridden by setting android:usesCleartextTraffic in the app manifest file.

You can refer to https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic

Upvotes: 1

Usama Shahid
Usama Shahid

Reputation: 865

If you are using some api that is hosted on some server. It must have https because in latest devices http request is forbidden.

Upvotes: 0

Related Questions