Welcome to onesignal-expo-plugin 👋
The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.
🚧 In Beta 🚧
Overview
This plugin is an Expo Config Plugin. It extends the Expo config to allow customizing the prebuild phase of managed workflow builds (no need to eject to a bare workflow). For the purposes of OneSignal integration, the plugin facilitates automatically generating/configuring the necessary native code files needed to get the OneSignal React-Native SDK to work. You can think of adding a plugin as adding custom native code.
Supported environments:
Install
expo install onesignal-expo-plugin
Configuration in app.json / app.config.js
Plugin
Add the plugin to the plugin array:
app.json
{
"plugins": [
[
"onesignal-expo-plugin",
{
"mode": "development",
"devTeam": "91SW8A37CR"
}
]
]
}
or
app.config.js
export default {
...
plugins: [
[
"onesignal-expo-plugin",
{
mode: process.env.NODE_ENV || "development",
devTeam: "91SW8A37CR"
}
]
]
};
Plugin Options
mode
: used to configure APNs environment entitlement.
"development"
"production"
devTeam
: optional - used to configure Apple Team ID. You can find your Apple Team ID by running expo credentials:manager
.
OneSignal App ID
Add your OneSignal App ID to your Expo constants via the extra
param:
Example:
{
"extra": {
"oneSignalAppId": "<YOUR APP ID HERE>"
}
}
You can then access the value to pass to the setAppId
function:
import OneSignal from 'react-native-onesignal';
import Constants from "expo-constants";
OneSignal.setAppId(Constants.manifest.extra.oneSignalAppId);
Alternatively, pass the app ID directly to the function:
OneSignal.setAppId("YOUR-ONESIGNAL-APP-ID");
Run
$ expo prebuild
$ expo run:ios
$ expo run:android
🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Show your support
Give a ⭐️ if this project helped you!
OneSignal
📝 License
Copyright © 2021 OneSignal.
This project is MIT licensed.