AirshipPush
public protocol AirshipPush : AnyObject, Sendable
Airship Push protocol.
-
If set, this block will be called when APNs registration succeeds or fails. This will be called in place of the
RegistrationDelegatedelegatesapnsRegistrationSucceededandapnsRegistrationFailedWithErrormethods.Declaration
Swift
@MainActor var onAPNSRegistrationFinished: (@MainActor @Sendable (APNSRegistrationResult) -> Void)? { get set } -
If set, this block will be called when the user notifications registration finishes. This will be called in place of the
RegistrationDelegatedelegatesnotificationRegistrationFinishedmethod.Declaration
Swift
@MainActor var onNotificationRegistrationFinished: (@MainActor @Sendable (NotificationRegistrationResult) -> Void)? { get set } -
If set, this block will be called when the notification authorization settings change. This will be called in place of the of the
RegistrationDelegatedelegatesnotificationAuthorizedSettingsDidChangemethod.Declaration
Swift
@MainActor var onNotificationAuthorizedSettingsDidChange: (@MainActor @Sendable (AirshipAuthorizedNotificationSettings) -> Void)? { get set } -
Checks to see if push notifications are opted in.
Declaration
Swift
@MainActor var isPushNotificationsOptedIn: Bool { get } -
Enables/disables background remote notifications on this device through Airship. Defaults to
true.Declaration
Swift
@MainActor var backgroundPushNotificationsEnabled: Bool { get set } -
Enables/disables user notifications on this device through Airship. Defaults to
false. Once set totrue, the user will be prompted for remote notifications.Declaration
Swift
var userPushNotificationsEnabled: Bool { get set } -
When enabled, if the user has ephemeral notification authorization the SDK will prompt the user for notifications. Defaults to
false.Declaration
Swift
var requestExplicitPermissionWhenEphemeral: Bool { get set } -
The device token for this device, as a hex string.
Declaration
Swift
@MainActor var deviceToken: String? { get } -
User Notification options this app will request from APNS.
Defaults to alert, sound and badge.
Declaration
Swift
var notificationOptions: UNAuthorizationOptions { get set } -
Custom notification categories. Airship default notification categories will be unaffected by this field.
Changes to this value will not take effect until the next time the app registers with updateRegistration.
Declaration
Swift
@MainActor var customCategories: Set<UNNotificationCategory> { get set } -
The combined set of notification categories from
customCategoriesset by the app and the Airship provided categories.Declaration
Swift
@MainActor var combinedCategories: Set<UNNotificationCategory> { get } -
Sets authorization required for the default Airship categories. Only applies to background user notification actions.
Declaration
Swift
@MainActor var requireAuthorizationForDefaultCategories: Bool { get set } -
Set a delegate that implements the PushNotificationDelegate protocol.
Declaration
Swift
@MainActor var pushNotificationDelegate: (any PushNotificationDelegate)? { get set } -
Set a delegate that implements the RegistrationDelegate protocol.
Declaration
Swift
@MainActor var registrationDelegate: (any RegistrationDelegate)? { get set } -
Notification response that launched the application.
Declaration
Swift
var launchNotificationResponse: UNNotificationResponse? { get } -
The current authorized notification settings. If push is disabled in privacy manager, this value could be out of date.
Note: this value reflects all the notification settings currently enabled in the Settings app and does not take into account which options were originally requested.
Declaration
Swift
var authorizedNotificationSettings: AirshipAuthorizedNotificationSettings { get } -
The current authorization status. If push is disabled in privacy manager, this value could be out of date.
Declaration
Swift
var authorizationStatus: UNAuthorizationStatus { get } -
Indicates whether the user has been prompted for notifications or not. If push is disabled in privacy manager, this value will be out of date.
Declaration
Swift
var userPromptedForNotifications: Bool { get } -
The default presentation options to use for foreground notifications.
Declaration
Swift
var defaultPresentationOptions: UNNotificationPresentationOptions { get set } -
enableUserPushNotifications()AsynchronousEnables user notifications on this device through Airship.
Note
The completion handler will return the success state of system push authorization as it is defined by the user’s response to the push authorization prompt. The completion handler success state does NOT represent the state of the userPushNotificationsEnabled flag, which will be invariably set to
trueafter the completion of this call.Declaration
Swift
func enableUserPushNotifications() async -> BoolParameters
completionHandlerThe completion handler with success flag representing the system authorization state.
-
The current badge number used by the device and on the Airship server.
Note
This property must be accessed on the main thread and must be set asynchronously using setBadgeNumber.Declaration
Swift
@MainActor var badgeNumber: Int { get } -
setBadgeNumber(_:Asynchronous) The current badge number used by the device and on the Airship server.
Declaration
Swift
func setBadgeNumber(_ newBadgeNumber: Int) async throws -
resetBadge()AsynchronousResets the badge to zero (0) on both the device and on Airships servers. This is a convenience method for setting the
badgeNumberproperty to zero.Declaration
Swift
func resetBadge() async throws -
Toggle the Airship auto-badge feature. Defaults to
falseIf enabled, this will update the badge number stored by Airship every time the app is started or foregrounded.Declaration
Swift
var autobadgeEnabled: Bool { get set } -
Time Zone for quiet time. If the time zone is not set, the current local time zone is returned.
Declaration
Swift
var timeZone: NSTimeZone? { get set } -
Enables/Disables quiet time
Declaration
Swift
var quietTimeEnabled: Bool { get set } -
Sets the quiet time start and end time. The start and end time does not change if the time zone changes. To set the time zone, see ‘timeZone’.
Update the server after making changes to the quiet time with the
updateRegistrationcall. Batching these calls improves API and client performance.Warning
This method does not automatically enable quiet time and does not automatically update the server. Please refer to
quietTimeEnabledandupdateRegistrationfor more information.Declaration
Swift
func setQuietTimeStartHour( _ startHour: Int, startMinute: Int, endHour: Int, endMinute: Int )Parameters
startHourQuiet time start hour. Only 0-23 is valid.
startMinuteQuiet time start minute. Only 0-59 is valid.
endHourQuiet time end hour. Only 0-23 is valid.
endMinuteQuiet time end minute. Only 0-59 is valid.
-
Quiet time settings. Setting this value only sets the start/end time for quiet time. It still needs to be enabled with
quietTimeEnabled. The timzone can be set withtimeZone.Declaration
Swift
var quietTime: QuietTimeSettings? { get set } -
Notification status updates
Declaration
Swift
@MainActor var notificationStatusPublisher: AnyPublisher<AirshipNotificationStatus, Never> { get } -
notificationStatusUpdatesAsynchronousNotification status updates
Declaration
Swift
var notificationStatusUpdates: AsyncStream<AirshipNotificationStatus> { get async } -
notificationStatusAsynchronousGets the current notification status
Declaration
Swift
var notificationStatus: AirshipNotificationStatus { get async } -
enableUserPushNotifications(fallback:Asynchronous) Enables user notifications on this device through Airship.
Note
The result of this method does NOT represent the state of the userPushNotificationsEnabled flag, which will be invariably set to
trueafter the completion of this call.Declaration
Swift
@discardableResult func enableUserPushNotifications(fallback: PromptPermissionFallback) async -> BoolParameters
fallbackThe prompt permission fallback if the display notifications permission is already denied.
Return Value
trueif user notifications are enabled at the system level, otherwisefalse.
-
Callback to be called when a notification is received in the foreground. This callback takes precedence over the delegate method if both are set.
Declaration
Swift
@MainActor var onForegroundNotificationReceived: (@MainActor @Sendable ([AnyHashable : Any]) async -> Void)? { get set } -
Callback to be called when a notification is received in the background. This callback takes precedence over the delegate method if both are set.
Declaration
Swift
@MainActor var onBackgroundNotificationReceived: (@MainActor @Sendable ([AnyHashable : Any]) async -> UIBackgroundFetchResult)? { get set } -
Callback to be called when a notification is received in the background. This callback takes precedence over the delegate method if both are set.
-
Callback to be called when a notification response is received. This callback takes precedence over the delegate method if both are set.
Declaration
Swift
@MainActor var onNotificationResponseReceived: (@MainActor @Sendable (UNNotificationResponse) async -> Void)? { get set } -
Callback to extend presentation options for foreground notifications. This callback takes precedence over the delegate method if both are set.
Declaration
Swift
@MainActor var onExtendPresentationOptions: (@MainActor @Sendable (UNNotificationPresentationOptions, UNNotification) async -> UNNotificationPresentationOptions)? { get set }
View on GitHub