Skip to main content

Configuring Push Notifications

Push notifications help send notifications to users about ESP RainMaker events. It is required to set up FCM and APNS environments for Android and iOS notifications respectively.

Configuring Push Notifications for Android

It's a 2 step process, configuring on the Google Firebase service and also in your Android application code.

Firebase Service Configurations.

  1. Configure your Android app for Push Notifications

  2. In the Firebase console, choose your project. In the left navigation pane, choose the gear icon, and then Project settings.

    firebase8

  3. Choose Service accounts. Click Generate new private key. Copy it to your clipboard.

    firebase9

  4. Log in to Rainmaker Dashboard with your Admin account. Go to deployment settings, then go to the Push Notifications tab.

    push_notification12

  5. Create a new platform application. Choose type Google Notification

    push_notification13

  6. Paste the whole file contents that you copied in step 3. Click Save.

    push_notification14

  7. You can now enable Push Notifications.

Android App Code Level Configurations

  1. Your android application must be registered with Firebase for push notifications to work. You can Register using these steps if not done already.

  2. Click Download google-services.json to obtain your Firebase Android config file (google-services.json). Replace existing google-services.json file with your downloaded file in the app module (app-level) directory of your app.

    firebase10

  3. Keep the remaining settings as it is.

    firebase11

  4. Continue with the Push Notifications Configuration.


Firebase Settings

To configure this further, you must log in with your Google account on the Firebase console.

Create a Firebase project

  1. In the Firebase console, click Create a project, then select or enter a Project name.

    firebase1

    firebase2

note

If you have an existing Google Cloud project, you can select the project from the dropdown menu to add Firebase resources to that project.

  1. (Optional) If you are creating a new project, you can edit the Project ID. To use a specific identifier, you must edit your project ID during this setup step. Firebase automatically assigns a unique ID to your Firebase project.
note

After Firebase provisions resources for your Firebase project, you cannot change your project ID.

  1. Click Continue.

    firebase3

  2. Click Create project (or Add Firebase if you're using an existing Google Cloud project).

    firebase4

note

For more information, see Create a Firebase project on the Firebase website.


Register your app with Firebase

To use Firebase in your Android app, you need to register your app with your Firebase project. Registering your app is often called "adding" your app to your project.

note

Visit Understand Firebase Projects to learn more about best practices and considerations for adding apps to a Firebase project, including how to handle multiple build variants.

  1. Go to the Firebase console.

  2. In the center of the Project Overview page, click the Android icon (plat_android) or Add an app to get started to launch the setup workflow.

    firebase5

  3. Enter your app's package name (application id) in the Android package name field. Click Register app.

    firebase6

    note

    Make sure to enter the package name that your app is using. The package name value is case-sensitive, and cannot be changed for this Firebase Android app after registering with your Firebase project.

    note

    For more information, see Register your app on the Firebase website.

Configuring Push Notifications for iOS

It's a 2 step process, configuring on the Apple Developer Console and also in your iOS application code.

Apple Developer Console Push Notifications Settings

  1. Log in to your Apple Developer account

    push_notification1

  2. App ID is required for push notifications to work. Create an App ID from Apple Developer console, if not created already.

  3. Then go to the Certificates tab. Click +.

    push_notification2

  4. Create a new certificate for Service - Apple Push Notification service SSL (Sandbox & Production). Click Continue.

    push_notification3

  5. Select the App Id of your app. Click Continue.

    push_notification4

  6. Now you will have to create Certificate signing request (CSR)

    push_notification5

  7. Open the Keychain Access utility. Then go to the Certificate Assistant > Request a certificate from a Certificate Authority.

    push_notification6

  8. In the Certificate Assistant dialog, enter an email address in the User Email Address field. Leave the CA Email Address field empty. Choose Saved to disk, and click Continue. Save the certificate.

    push_notification7

  9. Upload a Certificate signing request (CSR)

    push_notification8

  10. The certificate is created. Download and view it using Keychain Access.

    push_notification9

  11. Export your certificate from Keychain Access in p12 format.

    push_notification10

    Do not provide any password to protect the exported certificate.

    push_notification16

  12. You would require SSL Certificate and Private Key for enabling push notifications. To extract the SSL Certificate you can use the command:

    openssl pkcs12 -in yourP12Certificate.p12 -clcerts -nokeys

    To extract the Private Key you can use the command:

    openssl pkcs12 -in yourP12Certificate.p12 -nocerts -nodes

  13. Log in to Rainmaker Dashboard with your admin account. Go to deployment settings, then go to the Push Notifications tab.

    push_notification12

  14. Create a new platform application. Choose type - Apple Notification (APNS)

    push_notification13

  15. Paste the SSL Certificate and Private Key that you extracted in step 12. Click Save.

    push_notification11

    note

    The same certificate can be used for both Sandbox and Production environment. Sandbox environment is used to test notifications and debugging. While, APNS is used for distribution. You may repeat steps 13 and 14. Select type - Apple Sandbox (APNS_SANDBOX) to set push notifications for Sandbox environment.

  16. You can now enable Push notifications.


Enabling Push Notifications in ESP RainMaker Dashboard

  1. Log in to Rainmaker Dashboard with your admin account. Go to Deployment Settings > Push Notifications.

    push_notification12

  2. Enable push notifications using the toggle. You may also customize the events for which you wish to enable push notifications.

    push_notification15

    note

    You can disable push notifications using the same toggle.

iOS App Code Level Push Notification Settings

Push notifications are enabled by default in the project. The getNotificationPlatform() method in ios/Notification/ESPNotificationModule.swift should return a platform identifier string based on the build configuration:

  • Production builds: Return "APNS"
  • Development/Sandbox builds: Return "APNS_SANDBOX"

This platform identifier is used by the backend to identify the notification platform type. The method should check the build configuration (DEBUG vs RELEASE) and return the appropriate value:

@objc(getNotificationPlatform:reject:)
func getNotificationPlatform(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
// Development/Sandbox build - return APNS_SANDBOX
resolve("APNS_SANDBOX")
// Production build - return APNS
resolve("APNS")
}

On this page