1. Home
  2. Docs
  3. Documentation
  4. Push Notifications

Push Notifications

The app is using Google Cloud Messaging (within Firebase) to send push notifications to both iOS and Android devices. Push notifications are enabled by default in all of our React Native templates. However, they are set up to work with our staging Firebase project, so you’ll need to switch to your own project, similar to how you’ve done it for Firestore.

Setting Up Push Notifications with Your Own Firebase

To set them up with your own Firebase, all you need to do is to replace the Server Key of the notificationManager.js file with your own. 1. In Firebase, go to Project Settings -> Cloud Messaging and copy the Server Key to clipboard 2. In the source code, go to Core/notifications/firebase and replace the Server Key (firebaseServerKey variable) with your own:

const firebaseServerKey = "YOUR_KEY_HERE";

Here’s an example of how the updated server key should look like: That’s all you need to set up for Android. Push notifications should now work properly (make sure you re-build and re-run your app after making this change).

Code Documentation

The main component that handles sending push notifications is notificationManager, which resides at Core/notifications/notificationManager.js. All notifications are being sent through the sendPushNotification method.

const sendPushNotification = async (toUser, title, body, type, metadata = {})

To identify all the places that trigger push notifications, simply search for this method in the project.

Articles