Navigate back to the homepage

How to block calling unencrypted URL in react native

Infinitbility
React Native
July 25th, 2021 · 1 min read
How to block calling unencrypted URL in react native

Hello Friends,

Welcome To Infinitbility!

React Native provide default block all unsecure or not encrypted url but we made changes on project to call unencrypted url for development and when we want to deploy then we have to re-block unencrypted url calls, this article help you to reblock unsecure urls.

Let start today’s topic How to block calling unencrypted URL in react native

Introduction

We wil remove code on react native to block calling unsecured url and those code are we added when we want to call not encrypted url. then first we understand what are unsecured and unencrypted url?

unsecured and unencrypted urls are those who haven’t ssl certificate they looks like ( http://example.com ) and secured and encrypted url looks like ( https://example.com ) the diffrance is S.

Block unencrypted url in android

React Native provide android:usesCleartextTraffic="true" for allow unencrypted url in android then you have to remove android:usesCleartextTraffic="true" from AndroidManifest.xml ( project/android/app/src/main/AndroidManifest.xml ). it’s something looks like

1...
2
3 <application
4 android:name=".MainApplication"
5 android:icon="@drawable/icon"
6 android:label="@string/app_name"
7 android:roundIcon="@drawable/icon"
8 android:theme="@style/AppTheme"
9 android:requestLegacyExternalStorage="true"
10 android:usesCleartextTraffic="true"
11 >
12 <!--remove this line android:usesCleartextTraffic="true" -->
13 ...
14 </application>
15...

Block unencrypted url in iOS

React Native provide NSAllowsArbitraryLoads for allow unencrypted url in iOS then we have to remove from info.plist ( project/ios/project/info.plist ). it’s looks something like

1<key>NSAppTransportSecurity</key>
2<dict>
3 <key>NSAllowsArbitraryLoads</key>
4 <true/>
5 <key>NSExceptionDomains</key>
6 <dict>
7 <key>localhost</key>
8 <dict>
9 <key>NSExceptionAllowsInsecureHTTPLoads</key>
10 <true/>
11 </dict>
12 </dict>
13</dict>

Search NSAppTransportSecurity on info.plist file remove key dict pair and test your app.

Thanks for reading…

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Tutorials

React Native

Categories

More articles from Infinitbility

How to detect device rooted or jailbroken in react native

How to detect device rooted or jailbroken in react native

React Native Device is Rooted or Jailbroken

July 23rd, 2021 · 1 min read
How to get browser details in react

How to get browser details in react

get browser or device detail in react

July 20th, 2021 · 1 min read
© 2020–2021 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]