OneSignal
onesignalNotifications37 lines
Push notifications with segmentation, scheduling and campaign analytics.
Current — as published in v1.3.2. Written by hand for OneSignal, not generated.
The rule
Identity
OneSignal.login(userId)after sign-in,OneSignal.logout()after sign-out.- Missing
logout()leaves the device subscribed as the previous user, so the next person to sign in receives someone else's notifications. Treat it as part of the sign-out path, not a nice-to-have.
Permission
- Request in context, after your own explanation. On iOS the system prompt appears once per install and a decline is effectively permanent.
- Denied is a normal state — never block a feature on it.
Tags
- Non-personal attributes only: plan, locale, onboarding state.
- No email addresses, names, phone numbers or anything sensitive. This is a third-party store and purging it later is painful.
Payloads
- Notification content is visible on the lock screen and passes through Apple's and Google's infrastructure. Send an identifier and fetch details in-app.
Configuration
initialize()runs once at startup.- The plugin
modemust match the build:developmentAPNs in a production build fails silently. - The REST API key is server-side only — it can send to your whole audience.
Never
- Never expect this to work in Expo Go or a simulator.
- Never point a development build at the production OneSignal app.
As each tool receives it
The same guidance, in the shape each editor reads. Cursor and Claude Code are written separately by hand; the rest are derived from the Cursor rule.
.cursor/rules/onesignal.mdc
---
description: OneSignal conventions
globs: ["src/services/notifications/**"]
alwaysApply: false
---
# OneSignal
## Identity
- `OneSignal.login(userId)` after sign-in, `OneSignal.logout()` after sign-out.
- Missing `logout()` leaves the device subscribed as the previous user, so the
next person to sign in receives someone else's notifications. Treat it as part
of the sign-out path, not a nice-to-have.
## Permission
- Request in context, after your own explanation. On iOS the system prompt
appears once per install and a decline is effectively permanent.
- Denied is a normal state — never block a feature on it.
## Tags
- Non-personal attributes only: plan, locale, onboarding state.
- No email addresses, names, phone numbers or anything sensitive. This is a
third-party store and purging it later is painful.
## Payloads
- Notification content is visible on the lock screen and passes through Apple's
and Google's infrastructure. Send an identifier and fetch details in-app.
## Configuration
- `initialize()` runs once at startup.
- The plugin `mode` must match the build: `development` APNs in a production
build fails silently.
- The REST API key is server-side only — it can send to your whole audience.
## Never
- Never expect this to work in Expo Go or a simulator.
- Never point a development build at the production OneSignal app.
What else this module writes
Selecting OneSignal contributes more than a rule file — all of it merged with every other module you pick, with conflicts resolved rather than duplicated.
Environment
EXPO_PUBLIC_ONESIGNAL_APP_IDrequiredOneSignal App ID for this environment.ONESIGNAL_REST_API_KEYoptionalSends notifications from your backend. Never ship in the app.Dependencies
react-native-onesignal^5.5.0onesignal-expo-plugin^2.7.0dev
Folders
src/services/notifications/
Related
Put this in your repo
Adds OneSignal to a project this tool generated, without starting over. Files you have hand-edited are left alone.