Episode 1. Setup

What we will need from packages?

react-native-firebase — it will be our backend and our pub-sub host (Websockets). You can find package here. We will need to initialize CocoaPods for Firebase application for iOS. lodash — just to make our code cleaner. You can find package here.

So lets start with initializing empty project:

react-native init SimpleChat

Now lets add required packages straight away:

yarn add lodash && yarn add firebase

IMPORTANT: Do not do react-native link yet!

Android

Official installation guide. It’s better for you to use official installation guide, since it’s detailed enough.

iOS

Official installation guide, or you can read further, we are going to do this step by step.

Ok, since Android is set, we can start with CocoaPods I will assume that you’re using Mac or you already have installed Ruby (yup, it’s not dead, yet). If you don’t, please follow instructions here to install RVM and Ruby .

Lets init CocoaPods , more details how to install CocoaPods you can find here.

Navigate to your /ios folder, then run:

pod init

You will see that now /ios folder have Podfile ( package.json analog in CocoaPods world) and SimpleChat.xcworkspace . That mean that your project now have CocoaPods installed.

IMPORTANT: If you are using Xcode, please, open your project by clicking SimpleChat.xcworkspace instead of .xcodeproj file.

Now, we are ready for react-native link , navigate to your project root and execute:

react-native link

Currently, this command have two purposes:

It will add Firebase/Core to your Podfile . It will update build phase, and link Firebase library to your project nativly.

We still need two additional libs from Firebase package:

Firebase/Firestore — Firebase database Firebase/Auth — authorization with Firebase (for example if you have backend, there is no sense for you to install it, but in this tutorial I need this to identify users)

So, lets go and update our /ios/Podfile and add few lines of code. Now it should look like this:

platform :ios, '9.0'



target 'SimpleChat' do

pod 'Firebase/Core', '~> 5.20.2'

pod 'Firebase/Firestore', '~> 5.20.2'

pod 'Firebase/Auth', '~> 5.20.2'

end

NOTE: Please, do not forget to remove unnecessary stuff from the file, if you know what you’re doing.

When, react-native link is done and you added required packages, now you need navigate to /ios folder and run:

pod install

Now we need to modify our AppDelegate.m and add two lines of code, first next to you imports:

#import <Firebase.h>

The second one inside didFinishLaunchingWithOptions:(NSDictionary *)launchOptions right after definition:

[FIRApp configure];

All libs are set. Now we need to to setup Firebase application itself.