Legacy Mode

📘

Important note

This 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.co, 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.co 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.

👍

Developer Demo

Display our demo page in your app to test during development https://median.dev/onesignal-legacy


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

There are two ways to send personalized notifications under the legacy model.

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 logged 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 the oneSignalInfo 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.

/* Login Page Sample Code */
var gn_oneSignalUserId;

function median_onesignal_info(oneSignalInfo){
  gn_OneSignalUserId = oneSignalInfo.oneSignalUserId;
}

function yourLoginFunction(){
  if(gn_OneSignalUserId){
    $.ajax({
      url: updateUserRecord,
      type: "POST",
      data: {
        yourAppUserId: userId,
        oneSignalUserId: gn_OneSignalUserId
      },
      contentType: "application/json"
    });
  }
}

For more JavaScript examples, see OneSignal Info.

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:

  1. When the app registers with OneSignal and push tokens are initially created.
  2. When a page matching the configured URL is loaded in the app (such as a login success page).

Testing tip: Use .* 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.


Comparing the two options

CriteriaOption 1 (backend managed)Option 2 (External User ID)
Setup complexityHigher — requires backend storageLower — OneSignal manages the mapping
ControlFull — you manage every device recordLimited — depends on OneSignal's mapping
Multi-account supportYesLimited
Inactive device removalYesNo

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:

  1. User and device association: How your app associates users with devices. See Identifying & targeting users.
  2. Programmatic notifications: Transactional notification delivery. See Programmatic notifications.

Once you've updated both areas, disable Legacy Mode and rebuild your app.