This section covers how to setup push notification in React Native.

Enabling Push Notification in SDK

Set enablePush to true during SDK initialization. More details about SDK initialization can be found here

// Set config
const configs = new CastledConfigs()
configs.appId = "<app-id>"
configs.location = CastledLocation.US
configs.enablePush = true

// Initialize SDK

Native setup

  • Android

  • iOS

Step 1: Add required permissions

Add the following permission to android app AndroidManifest.xml. This allows the app to receive push notifications

    <manifest ...>
        <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
        <application ...>

Step 2: Firebase push messaging handling service

By default SDK takes care of push token fetch and notification handling once app gets the permission to post notification. In case the app has registered its own Firebase message service class (FirebaseMessagingService) for handling push tokens, SDK needs to be notified of the new token and any push notification received from Castled platform. Folow these instructions if you already have a FirebaseMessagingService registered.

Step 3: Notification default configs

You can also configure default values for Notification Channels and Notification Icons. Please find the instructions here