Push notifications using Firebase

Firebase incorporates a push notification service for iOS and Android, but it unfortunately doesn't provide any JavaScript on their SDK to use it. For this matter, an open source library was created bridging the Objective-C and Java SDKs into a React Native module: react-native-fcm.

We won't cover the installation of this module in this book, as it's a changing process that can be better followed on its repository at https://github.com/evollu/react-native-fcm.

We decided to abstract the logic for this module on our src/notifications.js file to make it available for every component while keeping its maintainability. Let's take a look at this file:

/*** src/notifications.js ***/import {Platform} from 'react-native'; ...

Get React Native Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.