Skip to content

Instantly share code, notes, and snippets.

@thuydao
Last active February 28, 2024 15:30
Show Gist options
  • Save thuydao/a1fecabaa33a9684f44c30cd472b6c7d to your computer and use it in GitHub Desktop.
Save thuydao/a1fecabaa33a9684f44c30cd472b6c7d to your computer and use it in GitHub Desktop.
Guide to development React Native
@thuydao
Copy link
Author

thuydao commented Feb 28, 2024

Setting up the development environment OSX

  1. Node & Watchman
    brew install node && brew install watchman

  2. Install XCode and Command Line Tools

  3. Create new application
    npx react-native@latest init AwesomeProject

@thuydao
Copy link
Author

thuydao commented Feb 28, 2024

FCM Firebase Cloud Message

Install & setup the app module
Install the messaging module
If you're developing your app using iOS, run this command

yarn add @react-native-firebase/app \
&& yarn add @react-native-firebase/messaging \
&& cd ios/ && pod install --repo-update \
&& cd ..

Error

The following Swift pods cannot yet be integrated as static libraries:

The Swift pod FirebaseCoreInternal depends upon GoogleUtilities, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.

Fix by add to ios/Podfile:

platform :ios, '12.4'
  ...
  ...
  
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true

  #....add any library need headers

Configure Firebase with Android credentials

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

buildscript {
  dependencies {
    // ... other dependencies
    // NOTE: if you are on react-native 0.71 or below, you must not update
    //       the google-services plugin past version 4.3.15 as it requires gradle >= 7.3.0
    classpath 'com.google.gms:google-services:4.4.1'
    // Add me --- /\
  }
}

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

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // <- Add this line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment