Push

@objc(UAPush)
public class Push : NSObject, Component, PushProtocol

This singleton provides an interface to the functionality provided by the Airship iOS Push API.

  • The shared Push instance.

    Declaration

    Swift

    @objc
    public static var shared: Push { get }
  • NSNotification event when a notification response is received. The event will contain the notification response object.

    Declaration

    Swift

    @objc
    public static let receivedNotificationResponseEvent: NSNotification.Name
  • Response key for ReceivedNotificationResponseEvent

    Declaration

    Swift

    @objc
    public static let receivedNotificationResponseEventResponseKey: String
  • NSNotification event when a foreground notification is received. The event will contain the payload dictionary as user info.

    Declaration

    Swift

    @objc
    public static let receivedForegroundNotificationEvent: NSNotification.Name
  • NSNotification event when a background notification is received. The event will contain the payload dictionary as user info.

    Declaration

    Swift

    @objc
    public static let receivedBackgroundNotificationEvent: NSNotification.Name
  • Enables/disables background remote notifications on this device through Airship. Defaults to true.

    Declaration

    Swift

    @objc
    public var backgroundPushNotificationsEnabled: Bool { get set }
  • Enables/disables user notifications on this device through Airship. Defaults to false. Once set to true, the user will be prompted for remote notifications.

    Declaration

    Swift

    @objc
    public var userPushNotificationsEnabled: Bool { get set }
  • Enables/disables extended App Clip user notifications on this device through Airship. Defaults to false. Once set to true, the user will be prompted for remote notifications if userPushNotificationsEnabled and the user currently has ephemeral authorization.

    Declaration

    Swift

    @available(*, deprecated, message: "Use requestExplicitPermissionWhenEphemeral instead")
    @objc
    public var extendedPushNotificationPermissionEnabled: Bool { get set }
  • When enabled, if the user has ephemeral notification authorization the SDK will promp the user for notifications. Defaults to false.

    Declaration

    Swift

    @objc
    public var requestExplicitPermissionWhenEphemeral: Bool { get set }
  • The device token for this device, as a hex string.

    Declaration

    Swift

    @objc
    public private(set) var deviceToken: String? { get set }
  • User Notification options this app will request from APNS. Changes to this value will not take effect until the next time the app registers with updateRegistration.

    Defaults to alert, sound and badge.

    Declaration

    Swift

    @objc
    public var notificationOptions: UANotificationOptions { 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

    @objc
    public var customCategories: Set<UNNotificationCategory> { get set }
  • The combined set of notification categories from customCategories set by the app and the Airship provided categories.

    Declaration

    Swift

    @objc
    public var combinedCategories: Set<UNNotificationCategory> { get }
  • Sets authorization required for the default Airship categories. Only applies to background user notification actions.

    Changes to this value will not take effect until the next time the app registers with updateRegistration.

    Declaration

    Swift

    @objc
    public var requireAuthorizationForDefaultCategories: Bool { get set }
  • Set a delegate that implements the PushNotificationDelegate protocol.

    Declaration

    Swift

    @objc
    public weak var pushNotificationDelegate: PushNotificationDelegate?
  • Set a delegate that implements the UARegistrationDelegate protocol.

    Declaration

    Swift

    @objc
    public weak var registrationDelegate: RegistrationDelegate?
  • Notification response that launched the application.

    Declaration

    Swift

    @objc
    public private(set) 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

    @objc
    public private(set) var authorizedNotificationSettings: UAAuthorizedNotificationSettings { get set }
  • The current authorization status. If push is disabled in privacy manager, this value could be out of date.

    Declaration

    Swift

    @objc
    public private(set) var authorizationStatus: UAAuthorizationStatus { get set }
  • 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

    @objc
    public private(set) var userPromptedForNotifications: Bool { get set }
  • The default presentation options to use for foreground notifications.

    Declaration

    Swift

    @objc
    public var defaultPresentationOptions: UNNotificationPresentationOptions
  • Enables 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 true after the completion of this call.

    Declaration

    Swift

    @objc
    public func enableUserPushNotifications(_ completionHandler: @escaping (_ success: Bool) -> Void)

    Parameters

    completionHandler

    The completion handler with success flag representing the system authorization state.

  • Indicates whether the user is opted in for push notifications or not.

    Declaration

    Swift

    @objc
    public var isPushNotificationsOptedIn: Bool { get }
  • The current badge number used by the device and on the Airship server.

    Note

    This property must be accessed on the main thread.

    Declaration

    Swift

    @objc
    public var badgeNumber: Int { get set }
  • Toggle the Airship auto-badge feature. Defaults to false If enabled, this will update the badge number stored by Airship every time the app is started or foregrounded.

    Declaration

    Swift

    @objc
    public var autobadgeEnabled: Bool { get set }
  • Resets the badge to zero (0) on both the device and on Airships servers. This is a convenience method for setting the badgeNumber property to zero.

    Note

    This method must be called on the main thread.

    Declaration

    Swift

    @objc
    public func resetBadge()
  • Quiet time settings for this device.

    Declaration

    Swift

    @objc
    public private(set) var quietTime: [AnyHashable : Any]? { get set }
  • Time Zone for quiet time. If the time zone is not set, the current local time zone is returned.

    Declaration

    Swift

    @objc
    public var timeZone: NSTimeZone? { get set }
  • Enables/Disables quiet time

    Declaration

    Swift

    @objc
    public 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 updateRegistration call. 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 quietTimeEnabled and updateRegistration for more information.

    Declaration

    Swift

    @objc
    public func setQuietTimeStartHour(
        _ startHour: Int,
        startMinute: Int,
        endHour: Int,
        endMinute: Int
    )

    Parameters

    startHour

    Quiet time start hour. Only 0-23 is valid.

    startMinute

    Quiet time start minute. Only 0-59 is valid.

    endHour

    Quiet time end hour. Only 0-23 is valid.

    endMinute

    Quiet time end minute. Only 0-59 is valid.

  • Registers or updates the current registration with an API call. If push notifications are not enabled, this unregisters the device token.

    Add a UARegistrationDelegate to UAPush to receive success and failure callbacks.

    Declaration

    Swift

    @objc
    public func updateRegistration()