Integrating Expo Plugin

How to integrate the Pushwoosh React Native & Expo SDK to your app for iOS and Android.

1. Install Plugin

1.1 Install the Pushwoosh Expo plugin using the Expo CLI

expo install pushwoosh-expo-plugin

1.2 Install Pushwoosh React Native SDK

npm install pushwoosh-react-native-plugin --save

1.3 Configure your app.json/app.config.js.

Add the plugin to the front of the plugin array.

{
  "plugins": [
    [
      "pushwoosh-expo-plugin",
      {
        "mode": "development",
      }
    ]
  ]
}

Plugin Prop

You can pass props to the plugin config object to configure:

Plugin props

mode

required

Used to configure APNs environment entitlement. "development" or "production"

Initialize Pushwoosh

import Pushwoosh from 'pushwoosh-react-native-plugin';
Pushwoosh.init({ 
    "pw_appid" : "YOUR_PUSHWOOSH_PROJECT_ID" , 
    "project_number" : "YOUR_GCM_PROJECT_NUMBER" 
});
Pushwoosh.register();

See Pushwoosh React Native integration

1.4 Prebuild

Prebuilding within Expo entails the generation of native runtime code for the project, resulting in the construction of the 'ios' and 'android' directories. Through prebuilding, the native modules that utilize CocoaPods, autolinking, and other configuration plugins are automatically linked and configured. You can conceptualize prebuild as a bundler for native code.

Executing expo prebuild initiates a custom managed workflow that combines the advantages of both bare workflows and managed workflows simultaneously.

npx expo prebuild

It is important to note that prebuilding is essential; without it, you might encounter a "TypeError: Cannot read property 'init' of null" error when attempting to run the app on a device.

1.5 Running

Executing the provided commands will prebuild and run your application. It's important to note that push notifications will not function in the iOS Simulator.

# Build and run your native iOS project
npx expo run:ios

# Build and run your native Android project
npx expo run:android

Last updated