Orchestration SDKs

Step 4. Configuring React Native apps for push notifications

PingOne Advanced Identity Cloud PingAM React Native

In this step, you configure your React Native project to support push notifications on both Android and iOS.

Configuring Android for push notifications

To enable push notifications on Android, you add the Firebase configuration file to your project and apply the Google services Gradle plugin.

  1. In Android Studio, open the android directory of your React Native project and switch to the Project view.

  2. Copy the google-services.json file that you downloaded from the Firebase console into the android/app directory of your project.

  3. To make the file available to the app, add the Google services Gradle plugin (com.google.gms.google-services) as a dependency to your project.

    1. In your root-level Gradle file (android/build.gradle or android/build.gradle.kts):

      • Kotlin

      • Groovy

      android/build.gradle.kts
      plugins {
          // ...
      
          // Add the dependency for the Google services Gradle plugin
          id("com.google.gms.google-services") version "4.4.2" apply false
      }
      android/build.gradle
      plugins {
          // ...
      
          // Add the dependency for the Google services Gradle plugin
          id 'com.google.gms.google-services' version '4.4.2' apply false
      }
    2. In your app-level Gradle file (android/app/build.gradle or android/app/build.gradle.kts):

      • Kotlin

      • Groovy

      android/app/build.gradle.kts
      plugins {
          // ...
      
          // Add the Google services Gradle plugin
          id("com.google.gms.google-services")
      }
      android/app/build.gradle
      plugins {
          // ...
      
          // Add the Google services Gradle plugin
          id 'com.google.gms.google-services'
      }
  4. Add the android.permission.POST_NOTIFICATIONS permission inside the <manifest> element in the android/app/src/main/AndroidManifest.xml file:

    Adding post notification permission to AndroidManifest.xml
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Configuring iOS for push notifications

To enable push notifications on iOS, you verify that the Push Notifications capability is enabled for your app in Xcode, and confirm it in the Apple Developer console.

  1. In Xcode, open the ios directory of your React Native project.

  2. In the Project navigator, select the project root.

  3. In the editor, under Targets, click your application, then click the Signing & Capabilities tab.

  4. Confirm that the application has the Push Notifications capability. If not, click + Capability to add it.

  5. With an admin account, log in to the Apple Developer console.

  6. Navigate to Program resources > Certificates, IDs & Profiles > Identifiers.

  7. Click the name of the application to which you are adding push notification support.

  8. On the Capabilities tab, ensure Push Notifications is selected.