Nowadays, there is an emergence of cross-platform hybrid applications on a large scale. Many top organizations are adapting different frameworks to develop or even entirely rewrite their mobile applications.
In this wave, React Native framework is gaining popularity for building cross-platform mobile applications. Began as a hackathon project, React Native is designed on Facebook’s React JavaScript toolkit, which extends the capabilities of the platform to native mobile app development.
This React Native Pentesting for Android Security Masterclass will cover everything there is to know about pen-testing React Native Android applications. In this blog, you will learn what React Native is, why there is a buzz around it, and the bridge concept.
It is assumed that the reader has prior knowledge about the following:
1. Basic knowledge of Android applications. Below are some references to get started:
2. Basic knowledge of JavaScript and webpack bundler
3. Introductory knowledge about React Native language (Core react native, JSX, Babel)
React Native is a JavaScript-based framework curated to develop native applications on platforms like Android and iOS. Facebook initially made React Native available as an open-source project in 2015. It quickly rose to the top of the list of tools used for mobile application development.
The tagline of React Native itself is “Learn once, write anywhere.” Thanks to the feature of re-using a large chunk of code of application across different platforms, React Native framework makes it easier to develop applications that provide a better user experience by utilizing the platform’s features along with building apps that are easier to develop and operate on a wider range of platforms and devices.
We can write applications for different platforms such as iOS, and Android with minor tweaks in code as per the platform which translates into saving great time and resources. React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces.
Some of the prominent examples of React Native apps are:
You can download the apks of these apps and play around.
Web+Mobile hybrid applications can display web content using WebView in native Android applications. Users can interact with the web content loaded inside the WebView. However, this type of architecture presents challenges when the application wants to access the user’s device resources such as camera, storage, various sensors, basic device information, etc.
React Native has made it possible to access these native features of the device along with JavaScript without deploying on the web. For this, a “JavaScript Bridge” concept is utilized, which we will discuss in the upcoming segment of this article.
React Native applications are written in a combination of JavaScript and JSX. JSX is a special syntax extension to JavaScript. A key concept in React Native is “Component”. A component is a piece of a user interface similar to the “Activities“ in JAVA-based Android applications. A React Native application can be made of multiple interconnected components. These components are composable and reusable throughout the application.
React Native brings React’s declarative UI framework to iOS and Android platforms. With React Native, you use native UI controls and have full access to the native platform features. As we discussed above, a React Native app can have multiple components. During the compilation, all of the components get compiled into one single file, as demonstrated below:
As you can see above, the application consists of multiple JS component files during development. However, during compilation into an APK, all the code in these multiple JS components gets bundled into one single file, “index.android.bundle.”
A very brief overview of the React Native application’s workflow is like this:
We write code in JavaScript
This JavaScript code gets converted into Native code
React Native deals with two realms: JavaScript and Native. Communication happens between these two realms over a communication channel called “Bridge.” As the name suggests, it provides a literal bridge between these two ends. Bridge provides a way for bidirectional and asynchronous communication between these two realms. In short, it provides a way of communication for two completely different technologies, JavaScript and Native.
Now that we know why React Native is important to Android applications and the bridge concept, we will next learn how to find out if an application is built on react native and how to reverse engineer native apps.
Stay tuned!