Skip to Content
Push NotificationsOverview

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 notifications step, the last onboarding screen by default, explains notifications, then calls requestPushPermission() when the user chooses to enable them.

If you remove that step but keep push, 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.

yarn remove:integration onesignal removes the notifications step along with OneSignal.

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.

app.config.js registers OneSignal’s config plugin only when the variable is set at build time. A build made without it has no notification service extension and no push entitlement. Set the variable wherever the native build runs: in .env.local for a local build, and in the EAS environment of the build profile for a cloud build. Adding the App ID to an app that was built without it needs a new native build.

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.

iosDeploymentTarget in app.config.js sets the minimum iOS version for the app and for OneSignal’s notification service extension. Without it the plugin builds the extension for iOS 11, which Xcode 27 refuses.

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, APNs mode and deployment target

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.

Last updated on