SDK: Expo plugin

Step 1: Import the PushSDK Library

Install the PushSDK using either your preferred package manager.

yarn add @pushly/push-sdk-expo

The plugin applies the native setup required for the Pushly React Native SDK

Step 2: Adding plugin to Expo config

Step 2.1: Google Services

Add your google-services.json file to app directory.

Step 2.2: app.config.js

Add the plugin to your Expo config and provide the App Group ID, Android application ID (must match the package inside google-services.json), and the path to your google-services.json file:

export default {
  expo: {
    ...,
    plugins: [
      [
        '@pushly/push-sdk-expo',
        {
          ios: {
            enableNse: true,
            nseTargetName: 'NotificationServiceExtension',
            nseBundleIdSuffix: '.NotificationServiceExtension',
            appGroupId: 'group.com.pushly.PushSdkReactNativeExample',
            iosDeploymentTarget: '15.0',
            swiftVersion: '5.0',
          },
          android: {
            applicationId: 'com.example.myapp',
            googleServicesFile: './app/google-services.json',
            applyGoogleServicesPlugin: true,
          },
        },
      ],
    ],
  },
};
Property
Definition

Enables plugin to install NotificationServiceExtension

User-defined name for NotificationServiceExtension. default: NotificationServiceExtension

Bundle id suffix for NotificationServiceExtension. Value is appended to PRODUCT_BUNDLE_IDENTIFIER env var. default: .NotificationServiceExtension

To ensure that the PushSDK can properly capture information the container should be named group.{app-bundle-id}.push.

Used to setup NotificationServiceExtension target in pbxproj file

Used to setup NotificationServiceExtension target in pbxproj file

Application ID used by Android application

Location of google-services.json file relative to app.plugin.js

Should google services plugin be applied in gradle.

Run expo prebuild --clean (or use EAS Build/custom dev clients) to generate native projects with the Pushly setup applied.

Step 3: iOS Setup

Step 3.1: Install Pods

Within your <project_root>/ios directory run: bundle exec pod install

Step 4: SDK Initialization

In your index.tsx or app.tsx file initialize the PushSDK using the example implementation code below.

Replace the REPLACE_WITH_SDK_KEY in the setConfiguration method with the SDK Key from the platform settings page.

Run your application on either an Android device or emulator (ensure the emulator has Google Play Store Services installed) or on an iOS device, if building for iOS, to make sure it builds correctly.

The code you added in the previous step will show the push permission dialog upon app open. This can be customized by using SDK methods to control when the dialog shows.

After accepting the dialog log into the platform and navigate to Notifications > Create Notification and send your first notification, targeting the appropriate Native: iOS or Native: Android channel, to your device.

Next Steps

Once you have confirmed the SDK is working properly you may continue to add additional optional functionality like:

Last updated