GOOGLE INTEGRATION

1.Go to the Firebase Console and create a Firebase project:

2.Dependency: yarn add react-native-google-singin

3.Update android/build.gradle with the following configuration:

buildscript {

    ext {

        buildToolsVersion = “27.0.3”

        minSdkVersion = 16

        compileSdkVersion = 27

        targetSdkVersion = 26

        supportLibVersion = “27.1.1”

        googlePlayServicesAuthVersion = “16.0.1” // <— use this version or newer

    }

    dependencies {

        classpath ‘com.android.tools.build:gradle:3.1.2’ // <— use this version or newer

        classpath ‘com.google.gms:google-services:4.1.0’ // <— use this version or newer

    }

allprojects {

    repositories {

 mavenLocal()

  google() // <— make sure this is included

        jcenter()

        maven {

            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm

            url “$rootDir/../node_modules/react-native/android”

        }

    }

}

4.Update android/app/build.gradle with the following configuration:

dependencies {

    implementation fileTree(dir: “libs”, include: [“*.jar”])

    implementation “com.android.support:appcompat-v7:23.0.1”

    implementation “com.facebook.react:react-native:+”

    implementation(project(“:react-native-community_google-signin”)) // <— add this dependency

}

FOR IOS

1.1: Apple bundle id from ios folder (AgribreedersSellerHub.xcodeproj) open

Bundle id is apple bundle id

2.Next, we copy the GoogleService-info.plist file to the Xcode project as shown in the screenshot below:

3.Now, we need to add the reversed client ID present in the GoogleService-info.plist file to the URL Types, as shown

 in the screenshot below:

4.Next step is to go to InfoURL Types then fill the URL Schemes as shown in the screenshot below:

FOR ANDROID

1.First, we need to create an Android app on Firebase. For that, we need a package name and certificate SHA-1 from our app. Then, we can register the Firebase app as shown below:

2.  For Android package name we have check in MainApplication.java file in android open  [package com.appname;

3.Next, we can get the SHA-1 key in the Keystore file. In the android/app directory, we can run the command:

3.1 for windows:keytool -exportcert -list -v –alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

3.2 for mac:keytool -exportcert -list -v –alias androiddebugkey -keystore ~/.android/debug.keystore

4.After successfully creating the Firebase setup app, we need to download the google-services.json file and copy it to the directory, as shown in the screenshot below:

Installing the React Native Firebase Package

In order to install react-native-firebase package version 6, we need to run the following command in our project command prompt:

# Using npm npm install –save @react-native-firebase/app

Then, the SHA-1 key will appear, as shown in the screenshot below:

After successfully creating the Firebase setup app, we need to download the google-services.json file and copy it to the directory, as shown in 

For iOS

We already have GoogleService-Info.plist added to Xcode. What is left is to allow Firebase on iOS to use the credentials. The Firebase iOS SDK must be configured during the bootstrap phase of your application.

To do this, we need to open our /ios/{projectName}/AppDelegate.m file, and add the following:

At the top of the file, we need to import the Firebase SDK:

#import <Firebase.h>

Within your existing didFinishLaunchingWithOptions method, we need to add the following to the top of the method:

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  // Add me — \/

  if ([FIRApp defaultApp] == nil) {

    [FIRApp configure];

  }

  // Add me — /\

  // …

}

Finally, we need to run the following command to finalize the installation of the CocoaPods package:

cd ios ; pod install

For Android

We need to configure Firebase with Android credentials. To allow Firebase on Android to use the credentials, the google-services plugin must be enabled on the project. This requires modification to two files in the Android directory.

First, add the google-services plugin as a dependency inside your android/build.gradle file:

buildscript {

  dependencies {

    // … other dependencies

    classpath ‘com.google.gms:google-services:4.2.0’

    // Add me — /\

  }

}

Lastly, execute the plugin by adding the following to the very bottom of your /android/app/build.gradle file:

apply plugin: ‘com.google.gms.google-services’

React Native Firebase Authentication Module

After the installation completes, we need to set up the parent Firebase package. Next, we need to install the child module for authentication. For that, we need to open a terminal and run the following command:

yarn add @react-native-firebase/auth

These are integration on Facebook

Leave a Reply