> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Legacy mode

> Send personalized OneSignal push notifications from apps that use Legacy Mode with the iOS v3 and Android v4 SDKs, and plan your migration.

> [!NOTE]
>
> **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, 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](https://docs.median.co/docs/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.

> [!TIP]
>
> **Test  with our demo page**
>
> We host a ready-made demo page at
>
> that calls the  features through the Median JavaScript Bridge.
> Load it inside your Median app during development, either by setting it
> as your app's website URL in App Studio or by navigating to it from your
> own site, and use it to confirm  works on a real device before
> you add it to your own pages.
>
> The demo page only works inside a Median app with  enabled.
> Opened in a regular mobile or desktop browser, the native features
> won't respond. Remember to switch your app back to your own URL before
> release.

## 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.

### 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 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.

Median JavaScript Bridge

```javascript JavaScript theme={null}
/* 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](https://docs.median.co/docs/identifying-targeting-users.md).

#### 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.

### 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.

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Set an External ID
median.onesignal.externalUserId.set({
  externalId: STRING // e.g. user@example.com
});

// Remove an External ID
median.onesignal.externalUserId.remove();
```

## Comparing the two options

| Criteria | Option 1 (backend managed) | Option 2 (External User ID) |
| - | - | - |
| **Setup complexity** | High - requires backend storage | Low - OneSignal manages the mapping |
| **Control** | Full - you manage every device record | Limited - depends on OneSignal's mapping |
| **Multi-account support** | Yes | Limited |
| **Inactive device removal** | Yes | No |

## Migrating away from legacy mode

To migrate to OneSignal's user-centric model, review [OneSignal's User Model Migration Guide](https://documentation.onesignal.com/docs/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](https://docs.median.co/docs/identifying-targeting-users.md).
2. **Programmatic notifications:** Transactional notification delivery. See [Programmatic notifications](https://docs.median.co/docs/programmatic-notifications.md).

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


## Related topics

- [Changelog archive](https://docs.median.co/docs/changelog-archive.md)
- [Google In-App Purchases](https://docs.median.co/docs/google-iap.md)
- [Customize push notifications](https://docs.median.co/docs/notification-customization.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.