Navigation

Send Mobile Push Notifications

Overview

You can send native push notifications to mobile client applications using the Push Notification Service.

Management Interface

The Push Notifications screen in the Realm UI lets you write notification drafts, send notifications to users and define notification rules.

There are four tabs in the Push Notifications screen:

Tab Name Description
Draft

In the Draft tab, you can view a list of the draft messages. For the draft messages, you can:

  • Duplicate draft messages
  • Edit draft messages
  • Delete draft messages
Sent

The Sent tab shows the messages that MongoDB Realm has already sent to registered clients. From here, you can view a list of the sent messages. For the sent messages, you can:

  • Resend sent messages.
  • Duplicate sent messages.
Config In the Config tab, you provide the FCM credentials (Sender ID and Legacy API key).
Rules You can optionally specify Push Notification Rules to restrict the types of push notifications that your application sends.

Send a Push Notification

You can send new Push Notifications from the Push Notifications page. Click the Send New Notification button to open the Send New Notification dialog. In this dialog, you provide the notification message, label, and the relevant topic audience.

Sending a new Push Notification

Set Up Clients to Receive Push Notifications

The general process of integrating Push Notifications in an Android application is as follows:

  1. Add a dependency for FCM.
  2. Create an FcmServicePushClient.
  3. Use the FcmServicePushClient’s register() method to register the client for push notifications.
  4. Use FirebaseMessaging’s subscribeToTopic() to subscribe to topics.
  5. Create a class that extends the abstract FirebaseMessagingService and implements the onMessageReceived() method. This class handles communication with FCM.
  6. Update AndroidManifest.xml file for your Android project to register your FirebaseMessagingService-derived class and a receiver for your application.

To see the latest information and detailed steps on FCM integration with Android Clients, see the official Set up a Firebase Cloud Messaging client app on Android guide.

To use FCM with Realm in an iOS app, follow these general steps:

  1. Create a valid Apple Push Notification service (APNs) certificate through the Apple Developer Member center.
  2. Copy the GoogleService-Info.plist file to your XCode project.
  3. Configure FCM and add your iOS app. When you register your app, FCM will return a registration token.

To see the latest information and detailed steps on FCM integration with iOS Clients, see the official Set up a Firebase Cloud Messaging client app on iOS guide.