Reference for OneSignal’s OSNotification object, including all payload fields, Android and iOS-specific properties, custom data, and click actions.
OSNotification
payload referenceOSNotification
class. Use this reference when receiving or handling notifications in your mobile app.
4096
bytes. To avoid truncation, keep payloads under 3500
bytes. The additionalData
field is limited to 2048
bytes.OSNotification
in your appOSNotification
object.
OneSignal.setNotificationWillShowInForegroundHandler(...)
notificationReceivedBlock
or UNNotificationServiceExtension
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.
Property | Type | Description |
---|---|---|
getBody() | String | Body text of the notification. |
getTitle() | String | Title of the notification. |
getLaunchURL() | String | URL opened when the notification is clicked. |
getNotificationId() | String | OneSignal notification UUID. |
getAdditionalData() | JSONObject | Custom key-value data set via dashboard or REST API. Max 2048 bytes. |
getTemplateId() | String | Template UUID, if sent using templates. |
getAndroidNotificationId() | int | Android native notification ID. |
getLargeIcon() | String | URL or resource name of large icon. |
getSmallIcon() | String | Small icon resource name. |
getSmallIconAccentColor() | String | Icon accent color in ARGB format. |
getSound() | String | Sound resource name played. |
getCollapseId() | String | Collapse key for notification replacement. |
getPriority() | int | Android priority (-2 to 2). |
getLedColor() | String | LED color in ARGB format. |
getLockScreenVisibility() | int | Lock screen visibility: 1 = public , 0 = private , -1 = secret . |
getFromProjectNumber() | String | Sender project number. |
getGroupedNotifications() | List<OSNotification> | Notifications included in a summary. |
getGroupKey() | String | Group key used in summaries. |
getGroupMessage() | String | Summary text. |
getBackgroundImageLayout() | BackgroundImageLayout | Object for background image layout and text colors. |
getActionButtons() | List<ActionButton> | Action buttons with icon, text, and ID. |
getRawPayload() | String | Full raw JSON string of the payload. |
Property | Type | Description |
---|---|---|
body | NSString | Body text of the notification. |
title | NSString | Title of the notification. |
launchURL | NSString | URL opened when the notification is clicked. |
notificationId | NSString | OneSignal notification UUID. |
additionalData | Dictionary | Custom key-value data set via dashboard or REST API. Max 2048 bytes. |
templateId | NSString | Template UUID, if sent using templates. |
subtitle | NSString | Subtitle text. |
category | NSString | iOS category identifier. |
threadId | NSString | Used to group notifications into threads (iOS 10+). |
badge | NSInteger | Absolute badge value. |
badgeIncrement | NSInteger | Amount to increment the badge. |
contentAvailable | BOOL | If content-available=1 , triggers background fetch. |
mutableContent | BOOL | If mutable-content=1 , triggers a Notification Service Extension. |
actionButtons | NSArray | iOS action buttons. |
rawPayload | NSDictionary | Full raw JSON of the payload. |
parseWithApns | Method | Converts raw APNS payload into an OSNotification. Use in service extensions. |
OSNotificationAction
(click events)Property | Type | Description |
---|---|---|
actionId | String | The ID of the clicked action button. |
type | enum | Opened (default tap) or ActionTaken (button tap). |
"custom"
object in the payload:
additionalData
available in the root of the APNS payload for easier access in custom handlers.
data
It will be available in the root of the APNS payload. Example:promo_code
without checking the custom dictionary.
Property | Type | Description |
---|---|---|
restoring | boolean | true if the notification was restored after device/app restart. |
restoring
flag. To avoid restoring old content, set a short or 0 TTL (time-to-live) on your notifications.