React Native(v0.73) Firebase Cloud Messaging(Notifee) / Analytics / Crashlytics Latest

Ajmal Hasan - Dec 13 '23 - - Dev Community

Firebase Cloud Messaging (FCM):

Firebase Cloud Messaging is a cloud solution for messages on iOS, Android, and web applications. It allows you to send messages to devices in a reliable, efficient, and scalable way. This can include messages to single devices, groups of devices, or devices subscribed to topics.

Firebase Analytics:

Firebase Analytics helps you understand how users interact with your app. It provides insights into user behavior, user engagement, and more.

Firebase Crashlytics:

Firebase Crashlytics helps you track and diagnose crashes in your application, providing insights into why they occurred.


Installation:

Analytics, Cloud messaging, Crashlytics, React Native Permissions

yarn add @react-native-firebase/app @react-native-firebase/analytics @react-native-firebase/messaging @react-native-firebase/crashlytics react-native-permissions @notifee/react-native && cd ios && pod install 
Enter fullscreen mode Exit fullscreen mode

or

npm i @react-native-firebase/app && @react-native-firebase/analytics && @react-native-firebase/messaging && @react-native-firebase/crashlytics && react-native-permissions && @notifee/react-native && cd ios && pod install
Enter fullscreen mode Exit fullscreen mode

Run pod install --repo-update if pod install fails.


New Project Setup in Firebase:

Go to the Firebase console to create a new project. Follow the prompts and modify them according to your needs. A new Firebase project can be initiated with three simple steps illustrated in the Firebase screenshots below.
Image description
Image description
Image description
Image description
The final step is to select a Google Analytics account to be linked with the project, select settings, and accept the terms. Then, click ‘create project.’


Register Your Application on Firebase Android

In the Firebase dashboard, register your Android application.

Image description
Image description
Image description


Android Native Configuration:

a) In android/build.gradle:
Image description

b) In android/app/build.gradle:
Image description
Image description
Image description

c) In main/AndroidManifest.xml:
Image description


Register Your Application on Firebase iOS

In the Firebase dashboard, register your iOS application.

Image description
Image description

Then Follow these steps:
https://rnfirebase.io/messaging/usage/ios-setup


iOS Native Configuration:

AppDelegate.h:
Image description

AppDelegate.mm:
Image description

Podfile:
Image description
Image description


Enabling server key from firebase dashboard:

Image description


Add firebase.json configuration in root-level directory:

You can refer firebase_json_temp.js to change boolean value as per requirement.


USAGE [ref:]

Notifee Usage in ReactNative->

Note: You can test cloud messaging on this site also

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .