top of page
Keyboard and Mouse

Blog

  • Writer's pictureLemanK

Tips: Cannot connect react-native runtime for simulators/physical devices

When you start development in your own device, both side might need to update network security setting to enable non-https connection.



Here's the tips on how to enable it on iOS and android.

 

iOS

You need to add property in Info.plist for enabling domain for using non-HTTPs server.


<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>{your ip address}</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> <key>localhost</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict>



 

Android

You need to create a file "network_security_config.xml" under "src/main/res/xml" directory and register this file in AndroidManifest.xml. It allow your physical devices/emulators to connect non-HTTPS server by giving domain names.



Before shown the example of my setting:


<?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="false">localhost</domain> <domain includeSubdomains="false">{your ip address}</domain> </domain-config> </network-security-config>

Comments


bottom of page