React Native For Ios And Android


How To Add A React Native App Icon To Ios And Android

Create Your First iOS and Android React Native App

Published by Florian Marcu on January 29, 2022

In this article, we are going to discuss the in and outs of the React Native App Icon for both iOS and Android. The app icon is a critical component of a mobile app since its always exposed to users. A great app icon can improve your app install numbers and can boost daily active users if its attractively designed. Anyone who is building a React Native app will eventually need to solve the issue of adding a React Native app icon to their mobile apps, prior to publishing them to the app stores.

At Instamobile, we add beautiful app icons to all of our React Native templates, across both platforms: iOS and Android. Were doing this very frequently, with every app template that we release, so I decided to document the process, to help out React Native developers who are still ramping up with app development.

How to Add a React Native App Icon to iOS

Uploading an app logo for iOS in React Native follows the exact same process as for the apps developed in Swift. Theres an existing default AppIcon image in the asset catalog already created for you in the Image.xcassets folder. Open your ejected React Native app in Xcode and locate the aforementioned Image.xcassets folder. Then drag and drop your app logo over the AppIcon image.

As you can see, there are about 20 different image sizes that you need to specify. Not all of them are mandatory, but Apple highly recommends you to add everything.

Same Experience On Both Ios And Android

If your goal was to build an app that would deliver the same experience on both Android and iOS platforms, then thats exactly whats going to happen opting for the React Native development solution.

Using separate frameworks for building separate Native apps to deliver the same experience is definitely time-consuming. Having said that, companies often launch their apps on iOS first. One of the reasons for this could be that an average iOS user spends more time on apps than an average Android user.

Clubhouse, the invitation-only social media platform, is a recent example of this.

Testing React Native Apps On Android And Ios

It was roughly a year ago when Facebook announced their intention to open source the React Native framework for building native apps. This wasnt a big surprise considering their own experiences with the HTML5 based application which got lots of negative feedback. Moving to native was clearly the right move and as they had some good and popular implementation for writing web apps there was a need to bridge the gap between the native and web/hybrid apps. With this combo, writing native apps for mobile platforms is actually very easy and it seems to work well across different setups. But, how to test and automate the testing of these sort of apps? Well take a look at this topic in this blog.

You May Like: Cheapest Android Phone In The World

Set Up Javascript Dependencies

Approach the root directory. Check for the installation of the yarn package manager. Here you will be building a new package with the following:


Install your React Native packages and navigate to your new package. A new folder will be created by Yarn, which will have all the dependencies related to JavaScript for building your project.

Create The Communication Channel Between The Widget And The React Native App

React Native Tutorial: Building iOS Apps with JavaScript ...

OK, now the fun part. Lets have our React Native app control what the widget shows. To do this, we have to implement a way for the React Native app to communicate with the widget. Were going to do this via a shared storage between the widget and the React Native app. This can be accomplished using theUserDefaultsiOSnativemodule.

We will make the React Native app write to UserDefaultsand have the widget read from it. The first problem we find is there is no official React Native way to interact with UserDefaults,andI didnt found any good library to do this. So lets implement this ourselves by creating a bridge between React Native and native iOS.

First, well create a shared space inside our app thatll allow communication between the widget and the app. This can be done with App Groups, which is located under the Capabilities tab.

Lets activate it and then select a group or add one if its empty:

OK, now that we have the App Groups enabled, lets implement a way for React Native to write to the UserDefaults by creating a native bridge.

Select your project, and right click to add a new file:

Select Cocoa Touch Class, and click Next:

Because this is a storage thatll be shared by the widget and the React Native app, lets call it SharedStorage. Select Objective-C, and click next:

Now you should see the new files on your project:

Lets edit those files. First copy this into the SharedStorage.h file:

And this into the SharedStorage.m file:

Don’t Miss: Automation Testing Tools For Android Applications

Build And Run Your Application From Command Line

You may build and launch your iOS application by the following command:

react-native run-ios

You can launch it on an iOS simulator or iOS device by specifying the iOS device name in react-native run-ios –device “myDeviceName”.

You may build and launch your Android application by the following command:

react-native run-android

You can launch it on an android emulator or android device by specifying the device id in react-native run-android –deviceId “myDeviceId” .

Control The Widget Content With The React Native App

On the React Native side, lets import the module:

import  from 'react-native' const SharedStorage = NativeModules.SharedStorage 

And then lets send some data to the storage:

You can do this, for example, on your App.js or wherever you find it appropriate to set the data on your React Native code:

Now, all thats left is to have the widget read the data and insert it into the UI. Were going to connect the widget to the UserDefaults, read its data, and then print the data on the Hello WorldtextLabel.

Go to your TodayViewController.swiftfile in the Widget folder, and edit the viewDidLoad function, like this:

//CHANGE THE GROUP NAMElet userDefaults = UserDefaultsoverride func viewDidLoad { super.viewDidLoad // Do any additional setup after loading the view from its nib. //ADD THIS do{

You can check the whole file here.

Important: Change the group name to the one you created on App Groups.

Lets run the application, and check the widget :

And thats it for iOS now to the Android part.

Don’t Miss: Best Free Meditation Apps Android

What Are The Limitations Of Developing Apps Using React Native

The fact is, the surfacing of bugs, errors, and security vulnerabilities are quite common when it comes to building native apps using React. Despite the popularity of React Native, you might encounter certain performance issues.

However, if you are well-aware regarding these problems, your React Native developers can stay on top of the seamless development of Native apps.

Below are some of the limitations or concerns that may arise when you build or replace native apps to React Native:

Create Your App In The App Center Portal To Obtain The App Secret

Simple Splash/Launch/Boot Screen in React Native (iOS and Android)

If you’ve already created your app in the App Center portal, you can skip this step.

  • Head over to
  • Sign up or log in and hit the blue button on the top right corner of the portal that says Add new and select Add new app from the dropdown menu.
  • Enter a name and an optional description for your app.
  • Select the appropriate OS and select React Native as the platform.
  • Hit the button at the bottom right that says Add new app.
  • Once you’ve created an app, you can obtain its App Secret on the Settings page on the App Center Portal. At the top right hand corner of the Settings page, click on the triple vertical dots and select Copy app secret to get your App Secret.

    Also Check: How To Read Ebooks On Android

    Is Swift Or React Native Better Documented

    Despite being new, Swift is quite well documented. I dont think Ive heard anyone complain about a lack of documentation in Swift. In terms of official documentation, React Native is also pretty good. Facebook has plenty of helpful tips and code samples along with regular docs.

    Community engagement and StackOverflow-wise, Id say Swift has an advantage as it has been around a year longer, was launched by Apple as an easier alternative to write iOS apps, and gets promoted by Apple at every opportunity. A quick comparison on the number of questions asked for Swift vs. React Native will show a very large delta. So for now, I dont think Swift and React Native can be compared as alternatives Swift is for mainstream iOS development but React Native is still somewhat specialized and appeals to a smaller subset of developers.

    Integrate The Sdk Automatically For React Native 060

    3.1.1 Integrate React Native iOS

  • Run pod install –repo-update from iOS directory to install CocoaPods dependencies.

  • Create a new file with the name AppCenter-Config.plist with the following content and replace with your app secret value. Don’t forget to add this file to the Xcode project .

    < ?xml version="1.0" encoding="UTF-8"?> < !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"""> < plist version="1.0"> < dict> < key> AppSecret< /key> < string> < /string> < /dict> < /plist> 
  • Modify the app’s AppDelegate.m file to include code for starting SDK:

  • Add these lines to import section above the #if DEBUG or #ifdef FB_SONARKIT_ENABLED declaration :
  • #import < AppCenterReactNative.h> #import < AppCenterReactNativeAnalytics.h> #import < AppCenterReactNativeCrashes.h> 
    • Add these lines to the didFinishLaunchingWithOptions method

    3.1.2 Integrate React Native Android

  • Create a new file with the name appcenter-config.json in android/app/src/main/assets/ with the following content and replace with your app secret value.

  • Note: If the folder named assets doesn’t exist, it should be created under “project_root/android/app/src/main/assets”

  • Modify the app’s res/values/strings.xml to include the following lines:

    < string name="appCenterCrashes_whenToSendCrashes" moduleConfig="true" translatable="false"> DO_NOT_ASK_JAVASCRIPT< /string> < string name="appCenterAnalytics_whenToEnableAnalytics" moduleConfig="true" translatable="false"> ALWAYS_SEND< /string> 
  • Don’t Miss: How To Get Kindle To Read To You On Android

    A Large Community To Back You Up

    Being an open-platform, React Native makes it easier for the developers to contribute and take the framework ahead. As a result, there are many tricks and tips that the community share with the developers to receive the utmost result out of the development.

    Besides this, since there are many React Native security vulnerabilities, the large community explores the way to offset these challenges. This means that you receive constant support.

    Android And Ios Development: 4 Biggest Differences


    1. Development Environment

    The only official Windows IDE to work with Android apps is Android Studio. There are some unofficial iOS simulators for Windows to test iOS apps, but their reliability isnât guaranteed by Apple. For macOS users, the situation is simpler as Android Studio works on Mac. So we recommend that React Native developers choose Macs for work. Building applications for both Android and iOS with React Native is possible with Windows, but testing is limited as XCode and its simulator is only available on macOS.

    2. Shadows

    Implementing shadows is one difficulty when working on cross-platform apps for iOS and Android. React Native lets you simply style your application with JavaScript. The style names and values match CSS for the web .

    We would use code like this to add a shadow:

    import React from 'react' import  from 'react-native' const styles = , title: , shadowTest: ,   shadowOpacity: 0.5,   shadowRadius: 10 }} class ShadowTest extends React.Component )}   )  }}export default ShadowTest 

    But Android has no shadow because it doesnât support shadows in React Native. If you require a shadow in your Android app, you have to use the elevation property. It elevates an element above the standard elements to cast a shadow. The size of the shadow depends on how much elevation you give the element. This style property doesnât have an effect on iOS apps, so you donât need to use the option.

    3. Implementing libraries

    4. Native elements

    Also Check: How To Make Android Application

    Building A React Native App For Ios

    The processes for building React Native apps for iOS and Android are similar until you start dealing with platform-specific APIs. Most of the UI elements available work for both Android and iOS platforms.

    React Native provides basic building block elements that are used to build complex UIs. Among the most important are:

    • Text is used to display text in the application e.g., < Text> Some Text< /Text>
    • View is a container with support for layout and style e.g., < View> < Text> Some Text< /Text> < /View>

    You can find the full list of core components and APIs for buttons, lists, images, styles, user inputs, and more in the React Native docs.

    The entry point for a React Native application is index.js. This contains the main component to render the application.

    import  from 'react-native' import App from './App' import  from './app.json' // registering the component to be rendered.AppRegistry.registerComponent =>  App) 

    Adding Assets To The React Native App

    There are numerous assets in an applicationthe main being launcher icons, push notification icons, and custom fonts. Basically, these components are for enhancing the user satisfaction rate. On similar lines, it is crucial that you make the React Native app as user-friendly as possible.

    As a result, you can change the appeal of the icon of the debug App. Similarly, push notification is an important feature of an app when it comes to bringing a user back to the application.

    The image that you choose for the push notification icon should have a transparent background for a better appeal.

    Besides images and icons, the font also has to play an important role in the utmost beautification of an app. As a result, you can develop functionality for fetching the required font from the rich font family.

    val fontTypefaces = HashMap< String,  Typeface> fundownloadFonts if val request = FontRequest,            R.array.com_google_android_gms_fonts_certs)val callback = object : FontsContractCompat.FontRequestCallback override funonTypefaceRequestFailed FontsContractCompat            .requestFont    }

    You can also load the fonts by making use of the ReactFontManager. You just have to call the font using the React Native in a similar manner as below:

    const styles = ,    } 

    Recommended Reading: Data Recovery Software For Android After Factory Reset

    Deploying A React Native App

    You can deploy your React Native app to:

    • This allows you download the generated binary, and to share it with others via the public install page.

    • Online stores: we have integrations for multiple different online stores. In these guides, we’ll show you how to publish to Google Play and to Apple’s App Store.

    What Do You Wish Was Better About Working In Rn

    React Native Splash Screens (iOS & Android)

    AJ: Accessibility. Im a huge accessibility advocate, I push for implementation of accessibility in anything I work on. But this is a bit of a struggle with React Native. Accessibility is an area of RN that doesnt yet have a lot of educational material out there. A lot of the principles for web still apply, but the correct way to implement accessibility in some areas isnt yet well established and with fewer semantic building blocks very little gets built in by default. So developers need to be even more aware and intentional about what they create.

    Michelle: React Native land seems like the wild wild west after coming from languages with well established patterns and libraries as well as the documentation to support it. These do currently exist for RN but because of how new this framework is and the slow adoption of it, there’s still a long way to go to make it accessible for more people by providing more examples and resources to refer to.

    Ash: I wish that the tools were more cohesive. Having worked in the Apple developer ecosystem for so long, I know how empowering a really polished developer tool can be. Not that Apples tools are perfect, far from it, but they are cohesive in a way that I miss. Theres usually one way to accomplish a task, but in React Native, Im often left figuring things out on my own.

    Don’t Miss: Http Google Com Android Devicemanager

    Code Signing For React Native Apps

    A React Native app can consists of two projects, an Android and an iOS – both have different signing procedures. If you click the Code Signing tab of your projects Workflow Editor, all iOS and Android code signing fields are displayed in one page for you. Follow our platform-specific instructions to code sign your app for both iOS and Android.

    Differences In Building Ios And Android Apps Using React Native

    You have picked React Native to build cross-platform native apps on both iOS and Android. The biggest perk here is that the code is shared across the platforms. Code once and it works on both iOS and Android. But there are practical differences between iOS and Android, that you have to tackle as a React Native developer. There is never a perfect one size fits all solution, which means you need to tailor some pieces based on the platform as well.

    Based on the projects I have worked on, and after seeing what others in the community have shared, about 85-90% of the code is shared between iOS and Android.

    85-90% code is shared between iOS and Android using React Native

    In this post, we will learn the differences between iOS and Android that you will encounter while building React Native apps.

    Also Check: How Do You Listen To Podcasts On Android

    Limitations Related To Abstract Layers

    The basic aim behind any application is to offer numerous features and functionalities to end users for better conversion rate. As a result, during the development of an app in React Native, an abstraction layer is added on the native platform to produce more functionalities.

    Since this is an abstract layer, bugs are not identified. Hence, a bug in the abstraction layer means a bug in the application. These are difficult to pinpoint and diagnose. Besides this, An abstraction level, in turn, implies that you have to depend on third-party services for ensuring that your framework remains relevant.

    Mobile App Development: React Native Vs Native

    Doctreat â React Native Mobile APP for Android and IOS ...

    React Native is a framework created by Facebook that allows you to develop native mobile apps for iOS and Android with a single JavaScript codebase.

    In 2012 Mark Zuckerberg commented, The biggest mistake we made as a company was betting too much on HTML5 as opposed to native. React Native was announced at Facebooks React.js conference in February 2015 and open-sourced in March 2015.

    With the rise of React Native popularity and the growing number of popular mobile apps being partially or completely rewritten in React Native, the question arises: Should mobile developers use React Native for mobile development instead of going full native with Java or Swift?

    Before we start comparing these languages and frameworks, lets first see how React Native builds a mobile app. React Native framework uses React.js library in order to create a true native mobile app. The important difference between React and React Native is that the latter uses native components instead of web components to create the user interface, along with JSX a syntax that is used to embed XML with JavaScript.

    This basically means that you can write mobile apps similar to how you would write web apps. Lets show this on a simple custom component example:

    We can immediately see the similarities to web development coding style. React Native components such as < TouchableOpacity> and < Text> are defined and organised exactly like HTML components such as < button> or < div> .

    Also Check: Best Bitcoin Mining App Android

    Share post:


    More like this

    How To Watch Redzone On Android

    Which Devices...

    Best App For Creating Android Apps

    Apps Provide...

    Best Full Games On Android

    Top 10...

    How Does Duo Work On Android

    Make Calls...