Important noteThis guide applies only to apps using the legacy OneSignal integration (iOS v3 SDK or Android v4 SDK). If your app was set up recently through Median, it’s already on the current SDK (v5+) with a user-centric data model — this page doesn’t apply to you. For new integrations, start with Get started with OneSignal.
What legacy mode is
By default, Median apps integrate with the latest OneSignal iOS and Android SDKs (v5+) and the user-centric data model. With Legacy Mode enabled, your app falls back to OneSignal’s previous iOS v3 and Android v4 SDKs, which use a device-centric data model where each device has a unique Player ID.Sending personalized notifications in legacy mode
There are many use cases for sending push notifications to specific users, either individually or as part of a group:- Alerting users of new messages or deliveries
- Re-engaging users based on past activity
- Sending promotional offers aligned with user preferences
Option 1: User–device in your backend
You can associate your app users and their devices via the OneSignal Player ID (oneSignalUserId) and then send push notifications to specific devices.
Obtain the oneSignalUserId from the oneSignalInfo object — typically after a successful sign-in — and record it in your database alongside the user’s account identifier. This gives you full control: you can send to specific devices, remove devices when users haven’t signed in for some time, and support multiple accounts on the same device.
There are two ways to obtain and store the Player ID.
Option 1a: Retrieve via JavaScript on your website
Add JavaScript to a login success page to retrieve theoneSignalInfo object. The OneSignal Player ID is available as oneSignalUserId.
iOS note: On iOS, oneSignalUserId will not be set if the user has declined the push notification permission prompt.
Option 1b: POST directly from the native app
Define an API endpoint URL. The app sends a POST request to that endpoint including the user’s push token and OneSignal Player ID, along with any session cookies and complete HTTP headers — which your backend can use to identify the user and match an account. The POST is sent:- When the app registers with OneSignal and push tokens are initially created.
- When a page matching the configured URL is loaded in the app (such as a login success page).
.* or All Pages for your URL pattern while testing until you’ve confirmed your endpoint is receiving the POST. If you still don’t receive it, verify the endpoint with cURL or Postman.
Option 2: External User IDs
Instead of managing Player IDs in your own database, you can use OneSignal’s External User ID to associate your own identifiers — such as an email address or account number — with the device record in OneSignal. OneSignal manages the user-device relationship for you, though the functionality is more limited.Comparing the two options
Migrating away from legacy mode
To migrate to OneSignal’s user-centric model, review OneSignal’s User Model Migration Guide before disabling Legacy Mode. The primary areas to update are:- User and device association: How your app associates users with devices. See Identifying & targeting users.
- Programmatic notifications: Transactional notification delivery. See Programmatic notifications.