Skip to main content
The OSNotification class represents the push notification payload in OneSignal’s SDKs. Use it to access notification title, body, custom data, and platform-specific properties when handling notifications in your app.
Push notification payloads are limited to 4096 bytes. To avoid truncation, keep payloads under 3500 bytes. The additionalData field is limited to 2048 bytes.

Accessing OSNotification in your app

All OneSignal SDKs provide a notification event listener that returns an OSNotification object:

Android fields

iOS fields


OSNotificationAction (click events)

Describes the user’s interaction with the notification.

Custom OneSignal payload structure

All OneSignal notifications include a special "custom" object in the payload:
This key is required for OneSignal SDKs to process the notification. If missing, notifications will not trigger click events or analytics. If you send pushes from another service to devices that also use OneSignal, filter by this key to prevent duplicate processing. See Push payload handling for guidance.

Move additionalData to APNs root

For iOS apps, you can place additionalData fields in the root of the APNs payload instead of inside the custom dictionary. This simplifies access in custom notification handlers. 1. Enable via the API Use the Update an app API and set:
2. Send a push with data The data fields appear in the APNs root payload:
You can now access promo_code directly without checking the custom dictionary.

Restored notifications (Android)

The Android SDK restores notifications after a device reboot or app restart.
Check the restoring flag to skip restored notifications. To prevent old notifications from restoring entirely, set a short or 0 TTL (time-to-live) when sending.

Push token formats

  • iOS Push (APNs): 64 characters, hexadecimal only (0-9, a-f). deviceToken.map {String(format: "%02x", $0)}.joined()
  • Android Push (FCM): Typically 163 characters, alphanumeric, may contain hyphens, colons, and underscores.

FAQ

What is the maximum payload size?

Push notification payloads are limited to 4096 bytes total. The additionalData field is limited to 2048 bytes. To avoid truncation, keep your total payload under 3500 bytes.

How do I identify a OneSignal notification in the raw payload?

All OneSignal notifications include a "custom" object with an "i" key containing the notification ID. Check for this key to distinguish OneSignal notifications from those sent by other providers.

Can I access additionalData in the APNs root payload?

Yes. Enable additional_data_is_root_payload via the Update an app API to place additionalData fields in the APNs root instead of inside the custom dictionary. See Move additionalData to APNs root for details.

Android notification categories

Configure notification channels for Android 8.0+ devices.

Mobile Service Extensions

Add rich media, badges, and confirmed receipt tracking.

Mobile SDK reference

Full reference for OneSignal’s mobile SDK methods and listeners.