OSNotification payload reference

This page explains the structure and fields of the OneSignal push notification payload via the OSNotification class. Use this reference when receiving or handling notifications in your mobile 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 trigger a notification event listener that returns an OSNotification object.

  • Android: OneSignal.setNotificationWillShowInForegroundHandler(...)
  • iOS: notificationReceivedBlock or UNNotificationServiceExtension

Use this object to access notification title, body, data, and other properties.

The OSNotification class provides all notification payload data accessible within SDK notification event listeners. It merges the original OSNotification and OSNotificationPayload classes into a single, getter-based interface.

Android fields

PropertyTypeDescription
getBody()StringBody text of the notification.
getTitle()StringTitle of the notification.
getLaunchURL()StringURL opened when the notification is clicked.
getNotificationId()StringOneSignal notification UUID.
getAdditionalData()JSONObjectCustom key-value data set via dashboard or REST API. Max 2048 bytes.
getTemplateId()StringTemplate UUID, if sent using templates.
getAndroidNotificationId()intAndroid native notification ID.
getLargeIcon()StringURL or resource name of large icon.
getSmallIcon()StringSmall icon resource name.
getSmallIconAccentColor()StringIcon accent color in ARGB format.
getSound()StringSound resource name played.
getCollapseId()StringCollapse key for notification replacement.
getPriority()intAndroid priority (-2 to 2).
getLedColor()StringLED color in ARGB format.
getLockScreenVisibility()intLock screen visibility: 1 = public, 0 = private, -1 = secret.
getFromProjectNumber()StringSender project number.
getGroupedNotifications()List<OSNotification>Notifications included in a summary.
getGroupKey()StringGroup key used in summaries.
getGroupMessage()StringSummary text.
getBackgroundImageLayout()BackgroundImageLayoutObject for background image layout and text colors.
getActionButtons()List<ActionButton>Action buttons with icon, text, and ID.
getRawPayload()StringFull raw JSON string of the payload.

iOS fields

PropertyTypeDescription
bodyNSStringBody text of the notification.
titleNSStringTitle of the notification.
launchURLNSStringURL opened when the notification is clicked.
notificationIdNSStringOneSignal notification UUID.
additionalDataDictionaryCustom key-value data set via dashboard or REST API. Max 2048 bytes.
templateIdNSStringTemplate UUID, if sent using templates.
subtitleNSStringSubtitle text.
categoryNSStringiOS category identifier.
threadIdNSStringUsed to group notifications into threads (iOS 10+).
badgeNSIntegerAbsolute badge value.
badgeIncrementNSIntegerAmount to increment the badge.
contentAvailableBOOLIf content-available=1, triggers background fetch.
mutableContentBOOLIf mutable-content=1, triggers a Notification Service Extension.
actionButtonsNSArrayiOS action buttons.
rawPayloadNSDictionaryFull raw JSON of the payload.
parseWithApnsMethodConverts raw APNS payload into an OSNotification. Use in service extensions.

OSNotificationAction (click events)

Describes the user’s interaction with the notification.

PropertyTypeDescription
actionIdStringThe ID of the clicked action button.
typeenumOpened (default tap) or ActionTaken (button tap).

Custom OneSignal payload structure

All OneSignal notifications include a special "custom" object in the payload:

{
  "custom": {
    "i": "the-notification-id"
  }
}

This key is required for OneSignal SDKs to process the notification. If missing, notifications will not trigger click events or analytics.

If sending a push from a different service to a device already using OneSignal, avoid duplicating notifications.


Optional: move additionalData to APNS root

For iOS apps, you can make additionalData available in the root of the APNS payload for easier access in custom handlers.

  1. Enable in app settings Use the Update an app API and set:
{
  "additional_data_is_root_payload": true
}
  1. Send push with data It will be available in the root of the APNS payload. Example:
{
  "aps": {
    "alert": { "title": "Sale", "body": "20% off all items!" }
  },
  "promo_code": "SPRING20"
}

Now you can directly access promo_code without checking the custom dictionary.


Restored notifications

Notifications will be restored by the Android SDK after a reboot or app restart.

PropertyTypeDescription
restoringbooleantrue if the notification was restored after device/app restart.

Restored notifications can be skipped using the restoring flag. To avoid restoring old content, set a short or 0 TTL (time-to-live) on your notifications.