Skip to content

Apple local push notification Add-on

This Add-on lets the app schedule and manage local push notifications directly on macOS. It wraps UNUserNotificationCenter of the Apple UserNotifications framework and provides notification permission requests, notification type registration, scheduling based on a time interval or a date, cancellation of scheduled notifications, removal of delivered notifications, retrieval of pending and delivered notifications, and setting the app icon badge. It does not process notification content; it passes the content to the OS as is.

Local push notifications do not go through the Hive Axyl server, so you register and use only this Add-on, without the Push module. This Add-on supports only macOS, so on iOS and Android, implement local push notifications with the Unity Mobile Notifications package.

Module information

Item Value
Package com.com2usplatform.hiveaxyl.push.addon.applenotification
Interface ILocalNotificationApplePlugin
Namespace Hive.Axyl.Push.Addon.AppleNotification
Registration method AddAppleNotification()
Supported platforms macOS
Minimum requirements macOS 15+, Unity 6000.0+
Prerequisites

Scheduling local push notifications does not require any separate capability settings or entitlements. An entitlement is a value that declares, in the signature, the Apple capabilities that the app uses. However, to set the InterruptionLevel of a notification to TimeSensitive or Critical, you need the entitlement listed in UNContentInterruptionLevel.

A delegate is an app object that the OS calls when an event such as a notification being presented or tapped occurs. The Add-on does not install or replace the app's UNUserNotificationCenterDelegate, so notification events are raised only when the app's delegate passes the notification callbacks to the OS callback forwarding methods.

Registration and retrieval

Register it in the registration step of HiveBootstrap.Initialize, and then retrieve it with HiveCore.TryResolve<T>().

using Hive.Axyl.Core;
using Hive.Axyl.Core.Unity;   // HiveBootstrap
using Hive.Axyl.Push.Addon.AppleNotification;

HiveBootstrap.Initialize(config, builder =>
{
    builder.AddAppleNotification();
});

if (HiveCore.TryResolve<ILocalNotificationApplePlugin>(out var localNotification))
{
    // Code that runs only in macOS builds
}
Not registered in the Unity Editor

This Add-on is registered only in players built for macOS. In the Unity Editor, it is not registered even when the Editor runs on macOS, so using HiveCore.Resolve<T>() throws RegistrationNotFoundException. Always check with TryResolve<T>() before you use it.

Method summary

Every method takes CancellationToken ct = default as the last parameter. For the calling conventions, see Call context.

Method Description
RequestPermissionAsync() Requests the notification permission.
RegisterCategoryAsync() Registers notification types and action buttons.
ScheduleTimeIntervalAsync() Schedules a notification to display after a specified amount of time.
ScheduleCalendarAsync() Schedules a notification to display at a specified date and time.
CancelPendingAsync() Cancels pending notifications.
CancelDeliveredAsync() Removes notifications delivered to Notification Center.
ListPendingAsync() Gets the list of pending notifications.
ListDeliveredAsync() Gets the list of notifications remaining in Notification Center.
SetBadgeCountAsync() Sets the app icon badge number.

The methods that the app's delegate calls to pass on OS callbacks are described separately in OS callback forwarding methods.

Methods

RequestPermissionAsync

Requests the notification permission with UNUserNotificationCenter.requestAuthorization(options:). The system permission dialog is displayed only on the first call; after that, the result that the app user previously selected is returned.

If the app user denies the permission, a Success whose Data.Granted is false is returned, not a Failure. Once the app's notifications are turned off, macOS ends permission requests with an error, but the Add-on returns this case as a Success whose Granted is false as well. Handle denial with Granted.

The app has a single notification permission, so it is shared with the Apple Push Notification service push notification Add-on. Whichever of the two Add-ons you use to get the permission, it applies to both, so request it in only one place.

Task<LocalNotificationAppleServiceRequestPermissionResult> RequestPermissionAsync(IReadOnlyList<UNLocalAuthorizationOption> options, CancellationToken ct = default)
Parameter Type Required Description
options IReadOnlyList<UNLocalAuthorizationOption> Required The list of permission options to request. If the list is empty, no options are requested.
Item Value
Response RequestPermissionResponse

Result cases — LocalNotificationAppleServiceRequestPermissionResult

Result case Wire code Description
Success — The permission request completed. Check whether the permission was granted in Data.Granted.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

Exceptions

Exception When thrown
ArgumentNullException When options is null

RegisterCategoryAsync

Registers notification types with UNUserNotificationCenter.setNotificationCategories(_:). A notification type is a unit that groups the action buttons and behavior options to display on a notification, and you specify it with NotificationContent.CategoryIdentifier when you schedule a notification. When the app user selects an action button, the identifier of that action is delivered through the NotificationOpened event.

Each call replaces all registered notification types with the requested list. Pass all the notification types that the app uses at once during the app initialization step.

Task<LocalNotificationAppleServiceRegisterCategoryResult> RegisterCategoryAsync(IReadOnlyList<CategorySpec> categories, CancellationToken ct = default)
Parameter Type Required Description
categories IReadOnlyList<CategorySpec> Required The complete list of notification types to register.
Item Value
Response RegisterCategoryResponse

Result cases — LocalNotificationAppleServiceRegisterCategoryResult

Result case Wire code Description
Success — The notification types were registered.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

Exceptions

Exception When thrown
ArgumentNullException When categories is null
ArgumentException When categories contains a null item or an item whose Identifier is empty

ScheduleTimeIntervalAsync

Schedules a notification to display after a specified amount of time, with UNTimeIntervalNotificationTrigger. If repeats is true, the notification repeats at the same interval.

Even without the notification permission, scheduling ends with Success, but the OS does not display the notification. Even if there are more than 64 pending notifications, scheduling ends with Success, but the OS drops some notifications, and which notifications are dropped is not guaranteed. Keep fewer than 64 pending notifications.

Task<LocalNotificationAppleServiceScheduleTimeIntervalResult> ScheduleTimeIntervalAsync(string notificationId, NotificationContent content, TimeSpan interval, bool repeats, CancellationToken ct = default)
Parameter Type Required Description
notificationId string Required The notification identifier that the app defines. Use this value to cancel the schedule or to find the notification in a list.
content NotificationContent Required The notification content to display.
interval TimeSpan Required The time to wait before the notification is displayed. It must be greater than 0, and if repeats is true, it must be 60 seconds or more.
repeats bool Required If true, the notification repeats every interval.
Item Value
Response ScheduleTimeIntervalResponse

Result cases — LocalNotificationAppleServiceScheduleTimeIntervalResult

Result case Wire code Description
Success — The notification was scheduled. The identifier of the scheduled notification is contained in Data.NotificationId.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

Exceptions

Exception When thrown
ArgumentNullException When notificationId or content is null
ArgumentException When notificationId is an empty string, interval is 0 or less, or repeats is true and interval is less than 60 seconds

Call example

using System;
using Hive.Axyl.Push.Addon.AppleNotification;

var result = await localNotification.ScheduleTimeIntervalAsync(
    "notice-1",
    new NotificationContent
    {
        Title = "{title}",
        Body  = "{body}",
        Sound = "default",   // Default notification sound
    },
    TimeSpan.FromMinutes(30),
    repeats: false);

if (result is LocalNotificationAppleServiceScheduleTimeIntervalResult.Success success)
{
    string notificationId = success.Data.NotificationId;   // Used to cancel the schedule
}

ScheduleCalendarAsync

Schedules a notification to display when date and time conditions are met, with UNCalendarNotificationTrigger. The notification is displayed at the time when all the fields specified in DateComponents match, and if repeats is true, it repeats daily, weekly, monthly, or yearly, depending on the combination of specified fields.

The Add-on passes the date conditions to the OS as is, without checking or changing them. If you schedule a date that has already passed with repeats set to false, scheduling ends with Success, but the notification is not displayed. If you specify Year when repeats is true, macOS displays the notification again endlessly even though that time cannot repeat, so do not specify Year for repeating schedules.

The limit on the number of pending notifications is the same as for ScheduleTimeIntervalAsync().

Task<LocalNotificationAppleServiceScheduleCalendarResult> ScheduleCalendarAsync(string notificationId, NotificationContent content, DateComponents dateComponents, bool repeats, CancellationToken ct = default)
Parameter Type Required Description
notificationId string Required The notification identifier that the app defines. Use this value to cancel the schedule or to find the notification in a list.
content NotificationContent Required The notification content to display.
dateComponents DateComponents Required The date and time conditions for displaying the notification.
repeats bool Required If true, the notification is displayed each time the dateComponents conditions are met again.
Item Value
Response ScheduleCalendarResponse

Result cases — LocalNotificationAppleServiceScheduleCalendarResult

Result case Wire code Description
Success — The notification was scheduled. The identifier of the scheduled notification is contained in Data.NotificationId.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

Exceptions

Exception When thrown
ArgumentNullException When any of notificationId, content, or dateComponents is null
ArgumentException When notificationId is an empty string

Call example

This example displays a notification every Monday at 9:00 AM. Because it is a repeating schedule, Year is not specified.

using Hive.Axyl.Push.Addon.AppleNotification;

var result = await localNotification.ScheduleCalendarAsync(
    "weekly-notice",
    new NotificationContent
    {
        Title = "{title}",
        Body  = "{body}",
    },
    new DateComponents
    {
        Weekday = 2,   // 1 is Sunday, 2 is Monday
        Hour    = 9,
        Minute  = 0,
    },
    repeats: true);

CancelPendingAsync

Cancels a pending notification that has not been displayed yet, with removePendingNotificationRequests(withIdentifiers:). The call ends with Success even if there is no schedule with the requested identifier.

Task<LocalNotificationAppleServiceCancelPendingResult> CancelPendingAsync(string notificationId, CancellationToken ct = default)
Parameter Type Required Description
notificationId string Required The identifier that you specified when you scheduled the notification to cancel.
Item Value
Response CancelPendingResponse

Result cases — LocalNotificationAppleServiceCancelPendingResult

Result case Wire code Description
Success — The schedule was canceled, or there was no schedule to cancel.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

Exceptions

Exception When thrown
ArgumentNullException When notificationId is null

CancelDeliveredAsync

Removes a notification displayed in Notification Center with removeDeliveredNotifications(withIdentifiers:). The call ends with Success even if there is no notification with the requested identifier.

Task<LocalNotificationAppleServiceCancelDeliveredResult> CancelDeliveredAsync(string notificationId, CancellationToken ct = default)
Parameter Type Required Description
notificationId string Required The identifier that you specified when you scheduled the notification to remove.
Item Value
Response CancelDeliveredResponse

Result cases — LocalNotificationAppleServiceCancelDeliveredResult

Result case Wire code Description
Success — The notification was removed, or there was no notification to remove.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

Exceptions

Exception When thrown
ArgumentNullException When notificationId is null

ListPendingAsync

Gets the list of pending notifications with getPendingNotificationRequests. For each notification, only the identifier, the scheduling method, and the next display time are returned.

Task<LocalNotificationAppleServiceListPendingResult> ListPendingAsync(CancellationToken ct = default)
Item Value
Response ListPendingResponse

Result cases — LocalNotificationAppleServiceListPendingResult

Result case Wire code Description
Success — The retrieval succeeded. If there are no pending notifications, Data.Requests is empty.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

ListDeliveredAsync

Gets the list of notifications remaining in Notification Center with getDeliveredNotifications. For each notification, only the identifier and the delivery time are returned.

Task<LocalNotificationAppleServiceListDeliveredResult> ListDeliveredAsync(CancellationToken ct = default)
Item Value
Response ListDeliveredResponse

Result cases — LocalNotificationAppleServiceListDeliveredResult

Result case Wire code Description
Success — The retrieval succeeded. If no notifications remain in Notification Center, Data.Notifications is empty.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

SetBadgeCountAsync

Sets the app icon badge number with UNUserNotificationCenter.setBadgeCount(_:). Specifying 0 clears the badge. The badge is not cleared even when the app user taps a notification, so call this method with 0 at the point when you want to clear the badge.

The app has a single app icon badge, so it is shared with the Apple Push Notification service push notification Add-on. Separately from the NotificationContent.Badge value in the notification content, this method changes the current app icon badge immediately.

Task<LocalNotificationAppleServiceSetBadgeCountResult> SetBadgeCountAsync(int count, CancellationToken ct = default)
Parameter Type Required Description
count int Required The badge number to display on the app icon. 0 clears the badge. The SDK passes the value to the OS as is without validating it, and the OS behavior for negative numbers is undefined, so enter a value of 0 or more.
Item Value
Response SetBadgeCountResponse

Result cases — LocalNotificationAppleServiceSetBadgeCountResult

Result case Wire code Description
Success — The badge was set.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

OS callback forwarding methods

These are the methods that the app's delegate calls to pass macOS notification callbacks to the Add-on. The Add-on does not install or intercept the app's UNUserNotificationCenterDelegate, so events are raised only when the delegate calls these methods. Call each method from the callback in the table below.

When to call Method Call result
userNotificationCenter(_:willPresent:withCompletionHandler:) NotifyWillPresentNotificationAsync() The NotificationPresented event is raised.
userNotificationCenter(_:didReceive:withCompletionHandler:) NotifyDidReceiveResponseAsync() The NotificationOpened event is raised.

A single app delegate receives both remote push notifications and local push notifications. The Add-on does not determine whether a received notification is one that it scheduled, so the app must distinguish the notifications and pass them to the appropriate Add-on. Pass remote push notifications whose request trigger is UNPushNotificationTrigger to the Apple Push Notification service push notification Add-on, and pass the remaining local push notifications to this Add-on. If you also need to distinguish local push notifications that were not scheduled with this Add-on, add an app-defined prefix to notificationId when you schedule notifications, or keep a list of the identifiers you scheduled, and identify notifications by their notification identifier.

NotifyWillPresentNotificationAsync

In userNotificationCenter(_:willPresent:withCompletionHandler:), passes a local push notification that is about to be displayed while the app is in the foreground to the Add-on. The Add-on raises the NotificationPresented event.

This method does not determine how the notification is presented. The app's willPresent delegate passes foreground presentation options, such as banner, sound, and badge, directly to the OS's completionHandler, and PresentationOptions in the response is always empty.

Task<LocalNotificationAppleServiceNotifyWillPresentNotificationResult> NotifyWillPresentNotificationAsync(NotificationPayload notification, CancellationToken ct = default)
Parameter Type Required Description
notification NotificationPayload Required The notification that contains the identifier and content of the UNNotification received in the callback.
Item Value
Response NotifyWillPresentNotificationResponse

Result cases — LocalNotificationAppleServiceNotifyWillPresentNotificationResult

Result case Wire code Description
Success — The notification was passed on.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

Exceptions

Exception When thrown
ArgumentNullException When notification is null

NotifyDidReceiveResponseAsync

In userNotificationCenter(_:didReceive:withCompletionHandler:), passes the local push notification that the app user tapped or dismissed, and the selected action, to the Add-on. Responses for dismissed notifications are delivered only for notification types registered with the CustomDismissAction option. The Add-on raises the NotificationOpened event.

Task<LocalNotificationAppleServiceNotifyDidReceiveResponseResult> NotifyDidReceiveResponseAsync(NotificationPayload notification, string actionIdentifier, CancellationToken ct = default)
Parameter Type Required Description
notification NotificationPayload Required The notification that contains the identifier and content of UNNotificationResponse.notification received in the callback.
actionIdentifier string Required The UNNotificationResponse.actionIdentifier value received in the callback. Pass it without processing.
Item Value
Response NotifyDidReceiveResponseResponse

Result cases — LocalNotificationAppleServiceNotifyDidReceiveResponseResult

Result case Wire code Description
Success — The notification and action were passed on.
UnknownOutcome UNKNOWN A new result that this SDK version does not recognize.
Failure FAILURE The call could not be completed. Check the cause with the HiveError in Problem.

Exceptions

Exception When thrown
ArgumentNullException When notification or actionIdentifier is null

Events

Both events are invoked on the engine main thread, so you can use engine APIs inside the handlers.

NotificationPresented

Raised when, just before a local push notification is displayed while the app is in the foreground, the app's delegate passes the notification with NotifyWillPresentNotificationAsync(). It delivers the notification that the delegate passed, without processing it.

event Action<NotificationPayload> NotificationPresented
Parameter Type Description
— NotificationPayload The notification displayed in the foreground.

NotificationOpened

Raised when the app user taps a local push notification or one of its actions, or dismisses a notification of a notification type registered with the CustomDismissAction option, and the app's delegate passes it on with NotifyDidReceiveResponseAsync(). It delivers the tapped notification together with the selected action.

event Action<LocalNotificationOpened> NotificationOpened
Parameter Type Description
— LocalNotificationOpened The tapped notification and the selected action.

Data types

ActionSpec

Settings for UNNotificationAction, an action button to display on a notification.

Field Type Required Description
Identifier string Required The action identifier. When the app user selects this action, it is delivered as LocalNotificationOpened.ActionIdentifier.
Title string Required The text to display on the button. Not recorded in SDK logs.
Options IReadOnlyList<UNNotificationActionOption> Required The list of action behavior options. If there are no options, it is an empty list.

CancelDeliveredResponse

No fields.

CancelPendingResponse

No fields.

CategorySpec

Settings for UNNotificationCategory, a notification type.

Field Type Required Description
Identifier string Required The notification type identifier. Put this value in NotificationContent.CategoryIdentifier when you schedule a notification. If it is empty, ArgumentException is thrown.
Actions IReadOnlyList<ActionSpec> Required The list of action buttons to display on notifications of this notification type.
IntentIdentifiers IReadOnlyList<string> Required UNNotificationCategory.intentIdentifiers, the list of Siri intent identifiers to associate with this notification type. If there are no intents to associate, it is an empty list.
Options IReadOnlyList<UNNotificationCategoryOption> Required The list of notification type options. If there are no options, it is an empty list.

DateComponents

DateComponents, the date and time conditions for a schedule made with ScheduleCalendarAsync(). The notification is displayed at the time when all the fields with specified values match, and fields that you do not specify are not included in the conditions. For example, specifying 0 for Hour sets a midnight condition, and not specifying it means there is no hour condition.

For a notification to display only once, specify Year, Month, Day, and the time, and schedule it with repeats set to false. An absolute date already determines the day of the week, so do not specify Weekday together with Year, Month, and Day. If the day of the week does not match, the condition is not met.

For repeating schedules, leave out Year and set the repeat cycle with the combination of fields that you specify.

Specified fields Repeat cycle
Hour, Minute Daily
Weekday, Hour, Minute Weekly
Day, Hour, Minute Monthly
Month, Day, Hour, Minute Yearly
Field Type Required Description
Year int? Optional The year. Do not specify it for repeating schedules.
Month int? Optional The month. The range is 1-12.
Day int? Optional The day. The range is 1-31.
Hour int? Optional The hour. The range is 0-23.
Minute int? Optional The minute. The range is 0-59.
Second int? Optional The second. The range is 0-59.
Weekday int? Optional The day of the week. Based on the Gregorian calendar, 1 is Sunday and 7 is Saturday. Use it for weekly repeats, and do not specify it together with Year, Month, and Day.
TimeZoneIdentifier string Required The identifier of the time zone in which the conditions are evaluated. Example: Asia/Seoul. If it is an empty string or an identifier that does not exist, the device's current calendar time zone is used.

DeliveredNotificationSummary

A summary of one notification remaining in Notification Center.

Field Type Required Description
NotificationId string Required The identifier that you specified when you scheduled the notification.
DeliveredAtUnixMillis long Required The time when the notification was delivered, in Unix epoch milliseconds.

ListDeliveredResponse

Field Type Required Description
Notifications IReadOnlyList<DeliveredNotificationSummary> Required The list of notifications remaining in Notification Center. If there are none, it is an empty list.

ListPendingResponse

Field Type Required Description
Requests IReadOnlyList<UNNotificationRequestSummary> Required The list of pending notifications. If there are none, it is an empty list.

LocalNotificationOpened

The value delivered through the NotificationOpened event. It contains both the notification that the app user tapped and the selected action.

Property Type Required Description
Notification NotificationPayload Required The notification that the app user tapped.
ActionIdentifier string Required UNNotificationResponse.actionIdentifier, the identifier of the action that the app user selected. If the user taps the notification itself, it is com.apple.UNNotificationDefaultActionIdentifier, the value of the UNNotificationDefaultActionIdentifier constant; if the user selects an action registered for the notification type, it is that action's ActionSpec.Identifier. If the user dismisses a notification of a notification type registered with the CustomDismissAction option, it is com.apple.UNNotificationDismissActionIdentifier, the value of the UNNotificationDismissActionIdentifier constant. If the delegate passes an empty string to NotifyDidReceiveResponseAsync(), it is an empty string, and the event is still raised in this case.

NotificationAttachment

Settings for UNNotificationAttachment, the media to attach to a notification. Only local files can be attached, and the Add-on does not download files from remote URLs. To attach a remote image, have the app save the file to the device, and then put in the URL of that file.

Field Type Required Description
Identifier string Required An attachment identifier that is unique within a notification.
LocalFileUrl string Required The local file URL string of the file to attach. Example: file:///.... If the URL cannot be parsed or the OS rejects the file, only this attachment is left out, and the notification is still scheduled.
TypeHint string Required Apple's Uniform Type Identifier (UTType) string that indicates the file type. If it is an empty string, the OS determines the type from the file extension.

NotificationContent

Settings for UNMutableNotificationContent, the content of the notification to schedule. The Add-on does not fill in any default values; it passes the specified values to the OS as is.

Field Type Required Description
Title string Required The notification title. Not recorded in SDK logs.
Subtitle string Required The notification subtitle. Not recorded in SDK logs.
Body string Required The notification body. Not recorded in SDK logs.
Badge int Required The badge number to display on the app icon when the notification is delivered. 0 does not change the badge, so to clear the badge, use SetBadgeCountAsync().
Sound string Required The notification sound. default uses the default notification sound, any other value uses the name of a notification sound file included in the app, and an empty string displays the notification without a sound.
CategoryIdentifier string Required The identifier of a notification type registered with RegisterCategoryAsync(). If you do not use a notification type, it is an empty string.
ThreadIdentifier string Required The thread identifier used to group related notifications for display. If you do not group them, it is an empty string.
InterruptionLevel UNContentInterruptionLevel Required The importance and delivery timing of the notification. If it is Unspecified, the notification is delivered with Active, the OS default.
RelevanceScore double Required A score in the range of 0.0 to 1.0 that the system refers to when determining the priority of the notification.
UserInfoJson string Required The custom data to include in the notification, as a JSON object string. Nested values are also included as is. If it is an empty string or not a JSON object, the notification is scheduled without custom data. Not recorded in SDK logs.
Attachments IReadOnlyList<NotificationAttachment> Required The list of local files to attach to the notification. If there are no attachments, it is an empty list.

NotificationPayload

The notification that you pass to the OS callback forwarding methods and receive through the NotificationPresented event. It contains the notification identifier and content.

Field Type Required Description
NotificationId string Required UNNotification.request.identifier, the identifier of the notification request. For a notification scheduled with this Add-on, it is the notificationId specified when the notification was scheduled.
Content NotificationContent Required The notification content.

NotifyDidReceiveResponseResponse

No fields.

NotifyWillPresentNotificationResponse

Field Type Required Description
PresentationOptions IReadOnlyList<UNForegroundPresentationOption> Required Always an empty list. The app's willPresent delegate passes foreground presentation options directly to the OS's completionHandler.

RegisterCategoryResponse

No fields.

RequestPermissionResponse

Field Type Required Description
Granted bool Required true if the app user granted the notification permission. Whether each option was granted is not returned.

ScheduleCalendarResponse

Field Type Required Description
NotificationId string Required The identifier of the scheduled notification. It is the same as the requested notificationId.

ScheduleTimeIntervalResponse

Field Type Required Description
NotificationId string Required The identifier of the scheduled notification. It is the same as the requested notificationId.

SetBadgeCountResponse

No fields.

UNNotificationRequestSummary

A summary of one pending notification.

Field Type Required Description
NotificationId string Required The identifier that you specified when you scheduled the notification.
TriggerKind NotificationTriggerKind Required The scheduling method of the notification.
NextTriggerAtUnixMillis long Required The time when the notification will be displayed next, in Unix epoch milliseconds. If there is no next display time, it is 0.

Enums

Specify Add-on enums by their C# member names. 'Value' in the tables is the integer used for serialization.

NotificationTriggerKind

The scheduling method of a pending notification.

C# member Value Description
Unspecified 0 The default value with no scheduling method specified.
TimeInterval 1 A notification scheduled with a time interval, as with ScheduleTimeIntervalAsync().
Calendar 2 A notification scheduled with date and time conditions, as with ScheduleCalendarAsync().
Push 3 A pending remote push notification. This does not apply to notifications scheduled with this Add-on.
Unknown 4 A notification scheduled with a method that this Add-on does not handle, such as location-based scheduling.

UNContentInterruptionLevel

UNNotificationInterruptionLevel, the importance and delivery timing of a notification.

C# member Value Description
Unspecified 0 The default value with no level specified. The notification is delivered with Active, the OS default.
Passive 1 Adds the notification only to the notification list without turning on the screen or playing a sound.
Active 2 Displays the notification immediately and turns on the screen, and plays a sound if a notification sound is set.
TimeSensitive 3 Displays the notification immediately and can display it even during Focus or Do Not Disturb. If the app does not declare the com.apple.developer.usernotifications.time-sensitive entitlement, the OS lowers it to Passive for delivery.
Critical 4 Plays a sound, ignoring Do Not Disturb. Requires the critical alert entitlement approved by Apple.

UNForegroundPresentationOption

UNNotificationPresentationOptions, the foreground notification presentation options. This is the type of NotifyWillPresentNotificationResponse.PresentationOptions, and this list is always empty.

C# member Value Description
Unspecified 0 The default value with no options.
Badge 1 Changes the app icon badge while displaying the notification.
Sound 2 Plays the notification sound while displaying the notification.
List 3 Displays the notification in Notification Center.
Banner 4 Displays the notification as a banner.

UNLocalAuthorizationOption

UNAuthorizationOptions, the permission options to request with RequestPermissionAsync().

C# member Value Description
Unspecified 0 The default value with no options.
Badge 1 Permission to change the app icon badge.
Sound 2 Permission to play notification sounds.
Alert 3 Permission to display notifications on the screen.
CarPlay 4 Permission to display notifications in a CarPlay environment.
CriticalAlert 5 Critical alert permission, which plays notification sounds while ignoring Do Not Disturb. Requires a separate entitlement approved by Apple.
ProvidesAppNotificationSettings 6 Tells the OS that the app has its own notification settings screen. The OS displays a button that goes to that screen.
Provisional 7 Provisional permission that delivers notifications quietly to Notification Center without a permission dialog.

UNNotificationActionOption

UNNotificationActionOptions, the behavior options of an action button.

C# member Value Description
Unspecified 0 The default value with no options.
AuthenticationRequired 1 The action runs only after the app user unlocks the device.
Destructive 2 Displays the button in a style that warns that the action deletes or discards data. It is usually displayed in red.
Foreground 3 Brings the app to the foreground when the app user selects the action.

UNNotificationCategoryOption

UNNotificationCategoryOptions, the notification type options.

C# member Value Description
Unspecified 0 The default value with no options.
CustomDismissAction 1 When the app user dismisses a notification of this type, the OS delivers the dismiss action to the app.
AllowInCarPlay 2 An option that displays notifications of this type in a CarPlay environment. macOS has no CarPlay, so the Add-on ignores this option.
HiddenPreviewsShowTitle 3 Displays the notification title even when the app user has turned off notification previews.
HiddenPreviewsShowSubtitle 4 Displays the notification subtitle even when the app user has turned off notification previews.