OSNotification Payload

The OSNotification Class provides the Notification Payload data accessible within the SDK Notification Event Handlers. This class require the Major Release Versions of the OneSignal SDK.

OSNotification Class

The OSNotification class is composed of all getters. The class combines the original OSNotification with data previously on the OSNotificationPayload class into a single large OSNotification class.

Type

Method/Property

Description

JSONObject
NSDictionary

getAdditionalData (Android)
additionalData (iOS)

Gets custom additional data that was sent with the notification. Set on the dashboard under Options > Additional Data or with the data field on the REST API.

int

getAndroidNotificationId (Android)

Gets the unique Android Native API identifier.

String
NSString

getNotificationId (Android)
notificationId (iOS)

Gets the OneSignal notification UUID.

String
NSString

getBody (Android)
body (iOS)

Gets the body text of the notification.

NSString

subtitle (iOS)

Message Subtitle, iOS only.

String
NSString

getTitle (Android)
title (iOS)

Gets the title text of the notification.

String
NSString

getLaunchURL (Android)
launchURL (iOS)

Gets the URL opened when opening the notification.

String

getLargeIcon (Android)

Gets the large icon set on the notification.

String
NSDictionary

getBigPicture (Android)
attachments (iOS)

Gets the big picture image set on the notification.

iOS 10+ only. Attachments sent as part of the rich notification

String

getSmallIcon (Android)

Gets the small icon resource name set on the notification.

String

getSmallIconAccentColor (Android)

Gets the accent color shown around small notification icon on Android 5+ devices. ARGB format.

BackgroundImageLayout

getBackgroundImageLayout (Android)

If a background image was set, this object will be available.

The following methods on this object return strings:

  • getBodyTextColor()
  • getImage()
  • getTitleTextColor()

String

getLedColor (Android)

Get LED string. Devices that have a notification LED will blink in this color. ARGB format.

String

getCollapseId (Android)

Gets the collapse id for the notfication.

List<ActionButton>
NSArray

getActionButtons (Android)
actionButtons (iOS)

The list of action buttons on the notification.

The following methods on this object return strings:

  • getIcon()
  • getId()
  • getText()

int

getPriority (Android)

The priority of the notification. Values range from -2 to 2 (see Android's NotificationCompat reference for more info.

String

getFromProjectNumber (Android)

Gets the Google project number the notification was sent under.

List<OSNotification>

getGroupedNotifications (Android)

Gets the notification payloads a summary notification was created from.

String

getGroupKey (Android)

Notifications with this same key will be grouped together as a single summary notification.

String

getGroupMessage (Android)

Gets the summary text displayed in the summary notification.

int

getLockScreenVisibility (Android)

Privacy setting for how the notification should be shown on the lockscreen of Android 5+ devices.

1 (Default) - Public (fully visible)
0 - Private (Contents are hidden)
-1 - Secret (not shown).

String

getSound (Android)

Gets the sound resource played when the notification is shown. Read more here

String, NSString

getTemplateId (Android)
templateId (iOS)

Unique Template Identifier from Templates.

String, NSString

getTemplateName (Android)

Name of Template from Templates.

OSMutableNotification

mutableCopy (Android)

Extends OSNotification

Methods

  • setAndroidNotificationId(int id)
  • setExtender(Extender extender)

Extender

getNotificationExtender (Android)

String
NSDictionary

getRawPayload (Android)
rawPayload (iOS)

Gets raw JSON payload string received from OneSignal.

Holds the raw APS payload received.

NSString

category (iOS)

iOS Notification category key previously registered to display with.

NSString

threadId (iOS)

iOS 10+ only. Groups notifications into threads

BOOL

contentAvailable (iOS)

True when the key content-available is set to 1 in the APNS payload. Used to wake your app when the payload is received.

See Apple's documenation for more details.

BOOL

mutableContent (iOS)

True when the key mutable-content is set to 1 in the APNS payload.

See Apple's documenation for more details.

NSInteger

badge (iOS)

The badge number assigned to the application icon.

NSInteger

badgeIncrement (iOS)

The amount to increment the badge icon number.

Method

parseWithApns (iOS)

Parses an APS push payload into a OSNotificationPayload object. Useful to call from your NotificationServiceExtension when the didReceiveNotificationRequest:withContentHandler: method fires.

OSNotificationAction Class

The action the user took on the notification.

Type

Method

Description

String
NSString

getActionId() (Android)
actionID (iOS)

Notification button identifier

ActionType

getType() (Android)
OSNotificationActionType (iOS)

The action type.

Enum:

  1. Opened - notification was clicked
  2. ActionTaken - button was clicked

Did this page help you?