Apple Push Notification service push notification Add-on
An Add-on that receives remote push notifications through Apple Push Notification service (APNs) on iOS and macOS. It wraps UNUserNotificationCenter of the Apple UserNotifications framework and the remote notification registration feature to provide notification permission requests, device token issuance, APNs environment checks, app icon badge settings, and retrieval of the notification that launched the app. It passes on the notification content exactly as the OS delivered it, without processing it.
The Add-on does not register the issued token with the Hive Axyl server. Register the token with UpsertTokenAsync of the Push module, and in ProviderType, specify the environment that you checked with GetProviderEnvironmentAsync().
Module information
| Item | Value |
|---|---|
| Package | com.com2usplatform.hiveaxyl.push.addon.apns |
| Interface | IAPNSPlugin |
| Namespace | Hive.Axyl.Push.Addon.APNS |
| Registration method | AddAPNS() |
| Supported platforms | iOS, macOS |
| Minimum requirements | iOS 17+, macOS 15+, Unity 6000.0+ |
Prerequisites
When you install this Add-on, the Push Notifications capability and the APNs environment entitlement are automatically added to the Xcode project generated at build time. An entitlement is a value that declares, in the signature, the Apple features that the app uses. A Development Build uses the sandbox environment, and a release build uses the production environment. On macOS, the entitlement is added only when you build to generate an Xcode project. However, you must enable the Push Notifications capability for the App ID in Apple Developer and issue a matching provisioning profile yourself.
A delegate is an app object that the OS calls when an event occurs, such as a remote notification registration result or a notification arrival. The Add-on does not install or replace the app's delegates, such as UIApplicationDelegate on iOS, NSApplicationDelegate on macOS, and UNUserNotificationCenterDelegate. Device token issuance completes and notification events occur only when the app's delegate passes the OS callbacks to the OS callback forwarding methods.
Registration and retrieval
Register it together with the Push module 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;
using Hive.Axyl.Push.Addon.APNS;
HiveBootstrap.Initialize(config, builder =>
{
builder.AddPush()
.AddAPNS();
});
if (HiveCore.TryResolve<IAPNSPlugin>(out var apns))
{
// Code that runs only in iOS and macOS builds
}
Not registered in the Unity Editor
This Add-on is registered only in players built for iOS or macOS. In the Unity Editor, it is not registered even if the platform matches, 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 its last parameter. For the calling conventions, see Call context.
| Method | Description |
|---|---|
| RequestAuthorizationAsync() | Requests notification permission. |
| GetNotificationSettingsAsync() | Gets the current notification permission status. |
| GetTokenAsync() | Obtains an APNs device token. |
| GetProviderEnvironmentAsync() | Checks the APNs environment that the app uses. |
| GetColdStartNotificationAsync() | Gets the notification that launched the app. |
| 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
RequestAuthorizationAsync
Requests notification permission with UNUserNotificationCenter.requestAuthorization(options:). The system permission dialog appears only on the first call; after that, the method returns the result that the app user chose previously.
If the app user denies permission, Success with Data.Granted set to false is returned, not Failure. On macOS, once the app's notifications are turned off, permission requests end with an error, but the Add-on returns Success with Granted set to false in this case as well, so the results match on both platforms. Determine whether permission was denied from Granted, and if you need the notification permission status, call GetNotificationSettingsAsync().
Because there is one notification permission for the entire app, it is shared with the Apple local push notification Add-on. Permission obtained through either Add-on applies to both.
| Parameter | Type | Required | Description |
|---|---|---|---|
options | IReadOnlyList<UNAuthorizationOption> | Required | List of permission options to request. If the list is empty, no options are requested. |
| Item | Value |
|---|---|
| Response | APNSServiceRequestAuthorizationResponse |
Result cases — ApnsServiceRequestAuthorizationResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The permission request completed. Check Data.Granted to see whether permission was 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 |
GetNotificationSettingsAsync
Gets the current notification permission status with getNotificationSettings. The Add-on does not interpret the status and returns the UNAuthorizationStatus value as is, so the app decides, for example, whether to direct the app user to the Settings app when the status is Denied.
| Item | Value |
|---|---|
| Response | APNSServiceGetNotificationSettingsResponse |
Result cases — ApnsServiceGetNotificationSettingsResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The retrieval succeeded. Check the permission status in Data.AuthorizationStatus. |
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. |
GetTokenAsync
Starts remote notification registration and returns the device token issued by APNs as a lowercase hexadecimal string. The registration result comes back when the app's delegate passes it on with NotifyDidRegisterForRemoteNotificationsAsync() or NotifyDidFailToRegisterAsync(), so GetTokenAsync() does not complete unless the delegate calls one of the two methods.
Because the Add-on does not save the token, it requests remote notification registration from the OS on every call. When the token is received, the TokenRefreshed event also occurs. If you call the method again while waiting for the result, the previous call ends with Failure whose Code is Cancelled.
| Item | Value |
|---|---|
| Response | APNSServiceGetTokenResponse |
Result cases — ApnsServiceGetTokenResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The token was issued. The token is contained in Data.Token. |
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. |
Distinguish the cause of Failure by Problem.Code.
Problem.Code | Cause |
|---|---|
Unavailable | The method was called on a simulator, or the delegate passed on a registration failure with NotifyDidFailToRegisterAsync(). This Add-on does not issue tokens on a simulator, so check on a real device. |
FailedPrecondition | The APNs environment entitlement is missing because the Push Notifications capability is not turned on. |
Cancelled | The call was canceled with CancellationToken, or GetTokenAsync() was called again while waiting for the result. |
Call example
To register a token, you need the APNs environment along with the token. Convert the environment that you checked with GetProviderEnvironmentAsync() to the Push module's provider enum and pass it to UpsertTokenAsync.
using Hive.Axyl.Push;
using Hive.Axyl.Push.Addon.APNS;
// push: IPushService retrieved with HiveCore.Resolve<IPushService>()
var tokenResult = await apns.GetTokenAsync();
var environmentResult = await apns.GetProviderEnvironmentAsync();
if (tokenResult is ApnsServiceGetTokenResult.Success token
&& environmentResult is ApnsServiceGetProviderEnvironmentResult.Success environment)
{
var providerType = environment.Data.Environment == ProviderEnvironment.ApnsSandbox
? UpsertTokenRequestProviderType.ApnsSandbox
: UpsertTokenRequestProviderType.Apns;
var result = await push.UpsertTokenAsync(new UpsertTokenRequest
{
Token = token.Data.Token,
ProviderType = providerType,
// Also specify TimezoneId, Country, Language, and Agreement.
});
}
GetProviderEnvironmentAsync
Reads aps-environment, the APNs environment entitlement signed into the app, and returns the APNs environment that the app uses. If the value is development, the environment is ApnsSandbox; if the value is production, it is Apns. If the entitlement is missing because the Push Notifications capability is not turned on, the method returns Failure whose Code is FailedPrecondition.
On iOS, the method reads this value from the provisioning profile included in the app. Apps installed from the App Store or TestFlight do not include a provisioning profile, so the method always returns Apns, the production environment.
Specify UpsertTokenRequest.ProviderType according to the returned environment.
Data.Environment | Value to specify in ProviderType |
|---|---|
ProviderEnvironment.Apns | UpsertTokenRequestProviderType.Apns |
ProviderEnvironment.ApnsSandbox | UpsertTokenRequestProviderType.ApnsSandbox |
| Item | Value |
|---|---|
| Response | APNSServiceGetProviderEnvironmentResponse |
Result cases — ApnsServiceGetProviderEnvironmentResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The retrieval succeeded. The environment is contained in Data.Environment. |
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. |
GetColdStartNotificationAsync
If the app user tapped a remote push notification while the app was not running and the tap launched the app, returns that notification. If the app's delegate passes the notification with NotifyColdStartNotificationAsync() at app startup, the Add-on keeps the notification, and the kept notification is cleared once it is returned. Call this method once each time the app launches, after NotifyColdStartNotificationAsync() completes.
Because the returned notification is built from the notification's original payload, InterruptionLevel, RelevanceScore, and LaunchImageName have default values. Check the original values in the aps dictionary of UserInfoJson.
Even when there is no notification to return, Data.Notification is not null but an empty notification whose fields all have default values. To check whether there is a notification, check that Data.Notification.UserInfoJson is not empty. An empty notification is returned in the following cases.
- A normal launch without tapping a notification
- A call after the notification has already been returned
- A call before
NotifyColdStartNotificationAsync()completes - A launch in which the delegate did not pass on the notification that launched the app
| Item | Value |
|---|---|
| Response | APNSServiceGetColdStartNotificationResponse |
Result cases — ApnsServiceGetColdStartNotificationResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The retrieval succeeded. If no notification launched the app, Data.Notification is an empty notification. |
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. |
Call example
using Hive.Axyl.Push.Addon.APNS;
var result = await apns.GetColdStartNotificationAsync();
if (result is ApnsServiceGetColdStartNotificationResult.Success success
&& !string.IsNullOrEmpty(success.Data.Notification.UserInfoJson))
{
ApnsNotification launchNotification = success.Data.Notification; // Notification that launched the app
}
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 when you want to clear the badge.
Because there is one app icon badge for the entire app, it is shared with the Apple local push notification Add-on. Separately from the ApnsNotification.Badge value contained in a notification, this method immediately changes the current app icon badge.
| Parameter | Type | Required | Description |
|---|---|---|---|
count | int | Required | Badge number to display on the app icon. 0 clears the badge. The SDK does not validate the value and passes it to the OS as is, and the OS behavior for a negative number is undefined, so enter a value of 0 or more. |
| Item | Value |
|---|---|
| Response | APNSServiceSetBadgeCountResponse |
Result cases — ApnsServiceSetBadgeCountResult
| 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
Methods that the app's delegate calls to pass iOS and macOS notification callbacks to the Add-on. Because the Add-on does not install or intercept the app's delegates, GetTokenAsync() completes and events occur only when the delegate calls these methods. Call each method from the callback in the table below.
| When to call | Method | Call result |
|---|---|---|
application(_:didRegisterForRemoteNotificationsWithDeviceToken:) | NotifyDidRegisterForRemoteNotificationsAsync() | The pending GetTokenAsync() returns the token, and the TokenRefreshed event occurs. |
application(_:didFailToRegisterForRemoteNotificationsWithError:) | NotifyDidFailToRegisterAsync() | The pending GetTokenAsync() ends with Failure whose Code is Unavailable. |
userNotificationCenter(_:willPresent:withCompletionHandler:) | NotifyWillPresentNotificationAsync() | The NotificationPresented event occurs. |
userNotificationCenter(_:didReceive:withCompletionHandler:) | NotifyDidReceiveResponseAsync() | The NotificationOpened event occurs. |
| When the notification that launched the app is found at app startup | NotifyColdStartNotificationAsync() | The notification for GetColdStartNotificationAsync() to return is ready. |
The Add-on does not check whether a notification passed to it is a remote push notification. Because a single app delegate receives both remote and local push notifications, pass only notifications whose request trigger is UNPushNotificationTrigger to NotifyWillPresentNotificationAsync() and NotifyDidReceiveResponseAsync(). If you pass local push notifications, the NotificationPresented and NotificationOpened events also occur for local notifications. Pass macOS local push notifications to the Apple local push notification Add-on.
When you also use the Unity Mobile Notifications package
On iOS, when the Unity Mobile Notifications package requests notification permission, it replaces the delegate of UNUserNotificationCenter with its own delegate and does not keep the existing delegate. If the app's delegate is replaced this way during the permission request that first displays the OS permission dialog, notification callbacks are not passed to this Add-on, and the NotificationPresented and NotificationOpened events do not occur. If you also use this package, reconnect the app's delegate right after the permission request completes.
NotifyDidRegisterForRemoteNotificationsAsync
Passes the device token that the OS delivered in application(_:didRegisterForRemoteNotificationsWithDeviceToken:) to the Add-on. The Add-on converts the token to a lowercase hexadecimal string, returns it to the pending GetTokenAsync(), and raises the TokenRefreshed event.
| Parameter | Type | Required | Description |
|---|---|---|---|
deviceToken | byte[] | Required | Raw bytes of the device token received in the callback. Pass them without converting them to a string. |
| Item | Value |
|---|---|
| Response | APNSServiceNotifyDidRegisterForRemoteNotificationsResponse |
Result cases — ApnsServiceNotifyDidRegisterForRemoteNotificationsResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The token was passed. |
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 deviceToken is null |
NotifyDidFailToRegisterAsync
Passes a remote notification registration failure from application(_:didFailToRegisterForRemoteNotificationsWithError:) to the Add-on. The pending GetTokenAsync() ends with Failure whose Code is Unavailable.
| Parameter | Type | Required | Description |
|---|---|---|---|
errorDescription | string | Required | Description of the error received in the callback. It is contained in Problem.Message of the Failure that the pending GetTokenAsync() returns. |
| Item | Value |
|---|---|
| Response | APNSServiceNotifyDidFailToRegisterResponse |
Result cases — ApnsServiceNotifyDidFailToRegisterResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The registration failure was passed. |
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 errorDescription is null |
NotifyWillPresentNotificationAsync
Passes a remote push notification that arrived while the app was in the foreground, from userNotificationCenter(_:willPresent:withCompletionHandler:), to the Add-on. The Add-on raises the NotificationPresented event.
This method does not decide how the notification is presented. The app's willPresent delegate passes foreground presentation options, such as the banner, sound, and badge, directly to the OS completionHandler, and PresentationOptions in the response is always empty.
| Parameter | Type | Required | Description |
|---|---|---|---|
notification | ApnsNotification | Required | Notification that contains the content of the UNNotification received in the callback. |
| Item | Value |
|---|---|
| Response | APNSServiceNotifyWillPresentNotificationResponse |
Result cases — ApnsServiceNotifyWillPresentNotificationResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The notification was passed. |
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
Passes the remote push notification that the app user tapped or dismissed, and the selected action, from userNotificationCenter(_:didReceive:withCompletionHandler:) to the Add-on. A dismissal response is delivered only for notification types registered with the customDismissAction option. The Add-on raises the NotificationOpened event.
| Parameter | Type | Required | Description |
|---|---|---|---|
notification | ApnsNotification | Required | Notification that contains the content of UNNotificationResponse.notification received in the callback. |
actionIdentifier | string | Required | UNNotificationResponse.actionIdentifier value received in the callback. Pass it without processing it. |
| Item | Value |
|---|---|
| Response | APNSServiceNotifyDidReceiveResponseResponse |
Result cases — ApnsServiceNotifyDidReceiveResponseResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The notification and action were passed. |
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 |
NotifyColdStartNotificationAsync
When the app is launched by a tap on a notification while the app was not running, passes the original payload of that notification to the Add-on at app startup. The Add-on keeps this notification and returns it once when GetColdStartNotificationAsync() is called.
On iOS, the notification that launched the app is contained in launchOptions[.remoteNotification] of the app launch options. On macOS, the response of the launch notification has no payload, so get the payload from the notification delivered to the delegate's userNotificationCenter(_:didReceive:withCompletionHandler:) right after the app launches.
| Parameter | Type | Required | Description |
|---|---|---|---|
userInfoJson | string | Required | The userInfo of the notification that launched the app, converted to a JSON object string. If you pass an empty string, an empty JSON object, or a string that is not a JSON object, nothing is kept, so pass an empty string if the app launched without a notification. |
| Item | Value |
|---|---|
| Response | APNSServiceNotifyColdStartNotificationResponse |
Result cases — ApnsServiceNotifyColdStartNotificationResult
| Result case | Wire code | Description |
|---|---|---|
Success | — | The notification was passed. |
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 userInfoJson is null |
Events
All three events are invoked on the engine main thread, so you can use engine APIs inside the handlers.
NotificationPresented
Occurs when a remote push notification arrives while the app is in the foreground and the app's delegate passes the notification with NotifyWillPresentNotificationAsync(). It passes on the notification content that the OS delivered without processing it.
| Parameter | Type | Description |
|---|---|---|
| — | ApnsNotification | Notification received in the foreground. |
NotificationOpened
Occurs when the app user taps a remote push notification or a notification action, or dismisses a notification of a notification type registered with the customDismissAction option, and the app's delegate passes it with NotifyDidReceiveResponseAsync(). It passes the tapped notification together with the selected action.
| Parameter | Type | Description |
|---|---|---|
| — | ApnsNotificationOpened | The tapped notification and the selected action. |
TokenRefreshed
Occurs each time the app's delegate passes a device token with NotifyDidRegisterForRemoteNotificationsAsync(), and a GetTokenAsync() call waiting for the result also completes with the same token. Because the Add-on does not register the new token with the Hive Axyl server, register the token received through the event again with UpsertTokenAsync.
| Parameter | Type | Description |
|---|---|---|
| — | string | Device token as a lowercase hexadecimal string. |
Data types
ApnsNotification
Original information from UNNotificationContent. The app is responsible for interpreting the meaning of the fields, such as extracting deep links or interpreting custom keys.
| Field | Type | Required | Description |
|---|---|---|---|
Title | string | Required | UNNotificationContent.title, the notification title. Not recorded in SDK logs. |
Subtitle | string | Required | UNNotificationContent.subtitle, the notification subtitle. Not recorded in SDK logs. |
Body | string | Required | UNNotificationContent.body, the notification body. Not recorded in SDK logs. |
Badge | int | Required | UNNotificationContent.badge, the badge number contained in the notification. Both a notification without a value and a notification that clears the badge have 0, so you cannot distinguish the two cases. |
Sound | string | Required | Sound name. Because UNNotificationContent has no public API for reading the sound name, it is an empty string in notifications received through notification callbacks, so check the sound name in aps.sound of UserInfoJson. Notifications returned by GetColdStartNotificationAsync() contain the aps.sound value. |
CategoryIdentifier | string | Required | UNNotificationContent.categoryIdentifier, the identifier of the notification type assigned to the notification. |
ThreadIdentifier | string | Required | UNNotificationContent.threadIdentifier, used to group related notifications for display. |
LaunchImageName | string | Required | UNNotificationContent.launchImageName, the name of the launch image to display when the app is launched from the notification. Provided only on iOS; it is an empty string on macOS. |
TargetContentIdentifier | string | Required | UNNotificationContent.targetContentIdentifier, used to determine the app screen that handles the notification. It is an empty string if there is no value. |
InterruptionLevel | UNNotificationInterruptionLevel | Required | UNNotificationContent.interruptionLevel, which indicates the importance and delivery timing of the notification. |
RelevanceScore | double | Required | UNNotificationContent.relevanceScore, in the range of 0.0 to 1.0, which the system refers to when determining the priority of the notification. It is 0.0 if there is no value. |
UserInfoJson | string | Required | The entire notification payload, including the aps dictionary and custom keys, as a JSON string. Nested values are also included as is, so the app parses the keys it needs. Not recorded in SDK logs. |
ApnsNotificationOpened
Value passed through the NotificationOpened event. It contains both the notification that the app user tapped and the selected action.
| Property | Type | Required | Description |
|---|---|---|---|
Notification | ApnsNotification | Required | 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 a custom action registered for the notification type, it is that action's 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 still occurs in this case. |
APNSServiceGetColdStartNotificationResponse
| Field | Type | Required | Description |
|---|---|---|---|
Notification | ApnsNotification | Required | Notification that launched the app. If there is no notification to return, it is not null but an empty notification whose fields all have default values; distinguish it by whether UserInfoJson is empty. |
APNSServiceGetNotificationSettingsResponse
| Field | Type | Required | Description |
|---|---|---|---|
AuthorizationStatus | UNAuthorizationStatus | Required | UNNotificationSettings.authorizationStatus, the current notification permission status. |
APNSServiceGetProviderEnvironmentResponse
| Field | Type | Required | Description |
|---|---|---|---|
Environment | ProviderEnvironment | Required | APNs environment determined from the app's aps-environment entitlement. |
APNSServiceGetTokenResponse
| Field | Type | Required | Description |
|---|---|---|---|
Token | string | Required | APNs device token as a lowercase hexadecimal string. Put it in UpsertTokenRequest.Token of the Push module. Because it is sensitive information, it is not recorded in plain text in SDK logs. |
APNSServiceNotifyColdStartNotificationResponse
No fields.
APNSServiceNotifyDidFailToRegisterResponse
No fields.
APNSServiceNotifyDidReceiveResponseResponse
No fields.
APNSServiceNotifyDidRegisterForRemoteNotificationsResponse
No fields.
APNSServiceNotifyWillPresentNotificationResponse
| Field | Type | Required | Description |
|---|---|---|---|
PresentationOptions | IReadOnlyList<UNNotificationPresentationOption> | Required | Always an empty list. The app's willPresent delegate passes foreground presentation options directly to the OS completionHandler. |
APNSServiceRequestAuthorizationResponse
| Field | Type | Required | Description |
|---|---|---|---|
Granted | bool | Required | true if the app user granted notification permission. Whether each option was granted is not returned; check the notification permission status with AuthorizationStatus of GetNotificationSettingsAsync(). |
APNSServiceSetBadgeCountResponse
No fields.
Enums
Specify Add-on enums by their C# member names. 'Value' in the tables is the integer used for serialization.
ProviderEnvironment
APNs environment determined from the app's aps-environment entitlement.
| C# member | Value | Description |
|---|---|---|
Unspecified | 0 | Default value with no environment specified. This value is not returned when the retrieval succeeds. |
Apns | 1 | Production environment. aps-environment is production. |
ApnsSandbox | 2 | Sandbox environment. aps-environment is development. |
UNAuthorizationOption
UNAuthorizationOptions, the permission options to request with RequestAuthorizationAsync().
| C# member | Value | Description |
|---|---|---|
Unspecified | 0 | 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 regardless of the mute switch and Focus. 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. |
UNAuthorizationStatus
UNAuthorizationStatus, the notification permission status retrieved with GetNotificationSettingsAsync().
| C# member | Value | Description |
|---|---|---|
Unspecified | 0 | Default value with no status specified. The OS does not return this value. |
NotDetermined | 1 | The app user has not yet chosen whether to allow notifications. |
Denied | 2 | The app user denied notification permission. |
Authorized | 3 | The app user granted notification permission. |
Provisional | 4 | Notifications can be delivered quietly to Notification Center with provisional permission. |
Ephemeral | 5 | Notifications can be scheduled or received for a limited time, as with an App Clip. |
UNNotificationInterruptionLevel
UNNotificationInterruptionLevel, the importance and delivery timing of a notification.
| C# member | Value | Description |
|---|---|---|
Unspecified | 0 | Default value with no level specified. Notifications returned by GetColdStartNotificationAsync() and empty notifications have this value. |
Passive | 1 | Adds the notification only to the notification list without turning on the screen or playing a sound. |
Active | 2 | Presents the notification at the default level. Turns on the screen and plays a sound if a notification sound is set. |
TimeSensitive | 3 | Presents the notification immediately and can present 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 regardless of the mute switch and Focus. Requires the critical alert entitlement. |
UNNotificationPresentationOption
UNNotificationPresentationOptions, the foreground notification presentation options. This is the type of APNSServiceNotifyWillPresentNotificationResponse.PresentationOptions, and this list is always empty.
| C# member | Value | Description |
|---|---|---|
Unspecified | 0 | Default value with no options. |
Badge | 1 | Changes the app icon badge while presenting the notification. |
Sound | 2 | Plays the notification sound while presenting the notification. |
List | 3 | Shows the notification in Notification Center. |
Banner | 4 | Shows the notification as a banner. |