Class iOSNotification
The iOSNotification class is used to 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.
Inherited Members
Namespace: Unity.Notifications.iOS
Assembly: Unity.Notifications.iOS.dll
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 iOSNotificationCenter.ScheduleNotification method.
Constructors
iOSNotification()
Create a new instance of iOSNotification and automatically generate a unique string for iOSNotification.Identifier with all optional fields set to default values.
Declaration
public iOSNotification()
iOSNotification(string)
Specify a iOSNotification.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 |
---|---|
int |
Body
The message displayed in the notification alert. For more information, refer to Apple documentation.
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. Push notification is sent to the device as JSON. The value for data key is set to the Data property on notification.
Declaration
public string Data { get; set; }
Property Value
Type | Description |
---|---|
string |
ForegroundPresentationOption
Presentation options for displaying the local notification when the app is running. Only works if iOSNotification.ShowInForeground is enabled and the user has allowed the requested permissions 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.
InterruptionLevel
The notification’s importance and required delivery timing.
Declaration
public NotificationInterruptionLevel InterruptionLevel { get; set; }
Property Value
Type | Description |
---|---|
NotificationInterruptionLevel |
RelevanceScore
The score the system uses to determine if the notification is the summary’s featured notification. For more information, refer to Apple documentation.
Declaration
public double RelevanceScore { get; set; }
Property Value
Type | Description |
---|---|
double |
ShowInForeground
Indicates whether the notification alert should be shown when the app is open.
Declaration
public bool ShowInForeground { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Subscribe to the iOSNotificationCenter.OnNotificationReceived event to receive a callback when the notification is triggered.
SoundName
The name of the sound to be played. Use null for system default sound. See Apple documentation for named sounds and sound file placement.
Declaration
public string SoundName { get; set; }
Property Value
Type | Description |
---|---|
string |
SoundType
The type of sound to be played.
Declaration
public NotificationSoundType SoundType { get; set; }
Property Value
Type | Description |
---|---|
NotificationSoundType |
SoundVolume
The volume for the sound. Use null to use the default volume. For information on the supported values, refer to Apple documentation.
Declaration
public float? SoundVolume { get; set; }
Property Value
Type | Description |
---|---|
float? |
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 iOSNotificationCenter.OnNotificationReceived or iOSNotificationCenter.OnRemoteNotificationReceived use this property to determine what caused the delivery to occur. You can do this by comparing iOSNotification.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> |