Push notifications
NativeExpress uses OneSignal to register devices and send push notifications on iOS and Android.
Permission during onboarding
The app initializes OneSignal at launch without requesting permission. The last
onboarding screen explains notifications, then calls
requestPushPermission() when the user chooses to enable them.
If you remove that screen, add a permission action elsewhere. Initialization alone does not ask the user. A user who has already denied permission may need to enable notifications in their device settings.
Identify a user
On sign-in, identifyPushUser() passes the Supabase user ID to OneSignal as its
External ID. This lets your backend address the user across their subscriptions.
The wrapper also adds their email when one is supplied.
Configuration
Set EXPO_PUBLIC_ONE_SIGNAL_APP_ID after completing platform setup.
Without it, the wrapper’s functions return without initializing OneSignal or
requesting permission. The app still runs, but it cannot receive OneSignal push
notifications.
The app already includes the OneSignal native module and Expo config plugin.
app.config.js selects the APNs mode from the EAS build profile: the production profile uses
production mode, while other profiles and local builds default to development.
ONESIGNAL_MODE can override that selection.
Files
- services/push.ts - OneSignal wrapper
- app/(public)/onboarding/notifications.tsx - Permission primer
- provider/SessionProvider.tsx - User identification
- app/_layout.tsx - Initialization
- app.config.js - OneSignal plugin and APNs mode
Use another push provider
App code imports initializePush(), requestPushPermission() and
identifyPushUser() from src/services/push.ts. To replace OneSignal, implement
those functions for your provider and update its native dependencies and config
plugins.
Your coding agent can help configure OneSignal through its agent tools. Test messages should target your test device or test segment.