Class iOSNotification
The iOSNotification class is used schedule local notifications. It includes the content of the notification and the trigger conditions for delivery. An instance of this class is also returned when receiving remote notifications..
Namespace: Unity.Notifications.iOS
Syntax
public class iOSNotification
Remarks
Create an instance of this class when you want to schedule the delivery of a local notification. It contains the entire notification payload to be delivered (which corresponds to UNNotificationContent) and also the NotificationTrigger object with the conditions that trigger the delivery of the notification. To schedule the delivery of your notification, pass an instance of this class to the ScheduleNotification(iOSNotification) method.
Constructors
iOSNotification()
Create a new instance of iOSNotification and automatically generate an unique string for Identifier with all optional fields set to default values.
Declaration
public iOSNotification()
iOSNotification(String)
Specify a Identifier and create a notification object with all optional fields set to default values.
Declaration
public iOSNotification(string identifier)
Parameters
Type | Name | Description |
---|---|---|
String | identifier | Unique identifier for the local notification tha can later be used to track or change it's status. |
Properties
Attachments
A list of notification attachments. Notification attachments can be images, audio or video files. Refer to Apple documentation on supported formats.
Declaration
public List<iOSNotificationAttachment> Attachments { get; set; }
Property Value
Type | Description |
---|---|
List<iOSNotificationAttachment> |
Badge
The number to display as a badge on the app’s icon.
Declaration
public int Badge { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Body
The message displayed in the notification alert.
Declaration
public string Body { get; set; }
Property Value
Type | Description |
---|---|
String |
CategoryIdentifier
The identifier of the app-defined category object.
Declaration
public string CategoryIdentifier { get; set; }
Property Value
Type | Description |
---|---|
String |
Data
Arbitrary string data which can be retrieved when the notification is used to open the app or is received while the app is running.
Declaration
public string Data { get; set; }
Property Value
Type | Description |
---|---|
String |
ForegroundPresentationOption
Presentation options for displaying the local of notification when the app is running. Only works if ShowInForeground is enabled and user has allowed enabled the requested options for your app.
Declaration
public PresentationOption ForegroundPresentationOption { get; set; }
Property Value
Type | Description |
---|---|
PresentationOption |
Identifier
The unique identifier for this notification request.
Declaration
public string Identifier { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
If not explicitly specified the identifier will be automatically generated when creating the notification.
ShowInForeground
Indicates whether the notification alert should be shown when the app is open.
Declaration
public bool ShowInForeground { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
Subscribe to the OnNotificationReceived event to receive a callback when the notification is triggered.
Subtitle
A secondary description of the reason for the notification.
Declaration
public string Subtitle { get; set; }
Property Value
Type | Description |
---|---|
String |
ThreadIdentifier
An identifier that used to group related notifications together.
Declaration
public string ThreadIdentifier { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
Automatic notification grouping according to the thread identifier is only supported on iOS 12 and above.
Title
A short description of the reason for the notification.
Declaration
public string Title { get; set; }
Property Value
Type | Description |
---|---|
String |
Trigger
The conditions that trigger the delivery of the notification. For notification that were already delivered and whose instance was returned by OnRemoteNotificationReceived or OnRemoteNotificationReceived use this property to determine what caused the delivery to occur. You can do this by comparing Trigger to any of the notification trigger types that implement it, such as iOSNotificationLocationTrigger, iOSNotificationPushTrigger, iOSNotificationTimeIntervalTrigger, iOSNotificationCalendarTrigger.
Declaration
public iOSNotificationTrigger Trigger { get; set; }
Property Value
Type | Description |
---|---|
iOSNotificationTrigger |
Examples
notification.Trigger is iOSNotificationPushTrigger
UserInfo
Key-value collection sent or received with the notification. Note, that some of the other notification properties are transfered using this collection, it is not recommended to modify existing items.
Declaration
public Dictionary<string, string> UserInfo { get; }
Property Value
Type | Description |
---|---|
Dictionary<String, String> |