UAPush

@interface UAPush : UAComponent

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

  • Enables/disables background remote notifications on this device through Urban Airship. Defaults to YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL backgroundPushNotificationsEnabled;

    Swift

    var backgroundPushNotificationsEnabled: Bool { get set }
  • Sets the default value for backgroundPushNotificationsEnabled. The default is YES. After the backgroundPushNotificationsEnabled value has been directly set, this value has no effect.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        BOOL backgroundPushNotificationsEnabledByDefault;

    Swift

    var backgroundPushNotificationsEnabledByDefault: Bool { get set }
  • Enables/disables user notifications on this device through Urban Airship. Defaults to NO. Once set to YES, the user will be prompted for remote notifications.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL userPushNotificationsEnabled;

    Swift

    var userPushNotificationsEnabled: Bool { get set }
  • Enables/disables sending the device token during channel registration. Defaults to YES. If set to NO, the app will not be able to receive push notifications.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL pushTokenRegistrationEnabled;

    Swift

    var pushTokenRegistrationEnabled: Bool { get set }
  • Sets the default value for userPushNotificationsEnabled. The default is NO. After the userPushNotificationsEnabled value has been directly set, this value has no effect.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        BOOL userPushNotificationsEnabledByDefault;

    Swift

    var userPushNotificationsEnabledByDefault: Bool { get set }
  • The device token for this device, as a hex string.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *deviceToken;

    Swift

    var deviceToken: String? { get }
  • The channel ID for this device.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *channelID;

    Swift

    var channelID: String? { get }
  • 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

    Objective-C

    @property (assign, readwrite, nonatomic)
        UANotificationOptions notificationOptions;

    Swift

    var notificationOptions: UANotificationOptions { get set }
  • Custom notification categories. Urban 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

    Objective-C

    @property (readwrite, strong, nonatomic)
        NSSet<UANotificationCategory *> *_Nonnull customCategories;

    Swift

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

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        NSSet<UANotificationCategory *> *_Nonnull combinedCategories;

    Swift

    var combinedCategories: Set<AnyHashable> { get }
  • Sets authorization required for the default Urban 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

    Objective-C

    @property (assign, readwrite, nonatomic)
        BOOL requireAuthorizationForDefaultCategories;

    Swift

    var requireAuthorizationForDefaultCategories: Bool { get set }
  • Set a delegate that implements the UAPushNotificationDelegate protocol.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<UAPushNotificationDelegate>
        pushNotificationDelegate;

    Swift

    weak var pushNotificationDelegate: UAPushNotificationDelegate? { get set }
  • Set a delegate that implements the UARegistrationDelegate protocol.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<UARegistrationDelegate>
        registrationDelegate;

    Swift

    weak var registrationDelegate: UARegistrationDelegate? { get set }
  • Notification response that launched the application.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable)
        UANotificationResponse *launchNotificationResponse;

    Swift

    var launchNotificationResponse: UANotificationResponse? { get }
  • The current authorized notification settings.

    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

    Objective-C

    @property (readonly, nonatomic)
        UAAuthorizedNotificationSettings authorizedNotificationSettings;

    Swift

    var authorizedNotificationSettings: UAAuthorizedNotificationSettings { get }
  • The current authorization status.

    Declaration

    Objective-C

    @property (readonly, nonatomic) UAAuthorizationStatus authorizationStatus;

    Swift

    var authorizationStatus: UAAuthorizationStatus { get }
  • The current authorized notification options.

    Note: Unlike authorizedNotificationSettings, this value may diverge from the settings enabled in the Settings app depending on whether user push notifications are enabled and which options were originally requested. This behavior has been maintained for backwards compatibility.

    @deprecated Deprecated - to be removed in SDK version 11.0. Please use authorizedNotificationSettings.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic)
        UANotificationOptions authorizedNotificationOptions;

    Swift

    var authorizedNotificationOptions: UANotificationOptions { get }
  • Indicates whether the user has been prompted for notifications or not.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) BOOL userPromptedForNotifications;

    Swift

    var userPromptedForNotifications: Bool { get }
  • The default presentation options to use for foreground notifications.

    Note: this property is relevant only for iOS 10 and above.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        UNNotificationPresentationOptions defaultPresentationOptions;
  • Toggle the Urban Airship auto-badge feature. Defaults to NO If enabled, this will update the badge number stored by Urban Airship every time the app is started or foregrounded.

    Declaration

    Objective-C

    @property (getter=isAutobadgeEnabled, assign, readwrite, nonatomic)
        BOOL autobadgeEnabled;

    Swift

    var isAutobadgeEnabled: Bool { get set }
  • Sets the badge number on the device and on the Urban Airship server.

    Note

    This method must be called on the main thread.

    Declaration

    Objective-C

    - (void)setBadgeNumber:(NSInteger)badgeNumber;

    Swift

    func setBadgeNumber(_ badgeNumber: Int)

    Parameters

    badgeNumber

    The new badge number

  • Resets the badge to zero (0) on both the device and on Urban Airships servers. This is a convenience method for setBadgeNumber:0.

    Note

    This method must be called on the main thread.

    Declaration

    Objective-C

    - (void)resetBadge;

    Swift

    func resetBadge()
  • Tags for this device.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic) NSArray<NSString *> *_Nonnull tags;

    Swift

    var tags: [String] { get set }
  • Allows setting tags from the device. Tags can be set from either the server or the device, but not both (without synchronizing the data), so use this flag to explicitly enable or disable the device-side flags.

    Set this to NO to prevent the device from sending any tag information to the server when using server-side tagging. Defaults to YES.

    Declaration

    Objective-C

    @property (getter=isChannelTagRegistrationEnabled, assign, readwrite, nonatomic)
        BOOL channelTagRegistrationEnabled;

    Swift

    var isChannelTagRegistrationEnabled: Bool { get set }
  • Enables user notifications on this device through Urban 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 YES after the completion of this call.

    Declaration

    Objective-C

    - (void)enableUserPushNotifications:(nonnull void (^)(BOOL))completionHandler;

    Swift

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

    Parameters

    completionHandler

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

  • Adds a tag to the list of tags for the device. To update the server, make all of your changes, then call updateRegistration to update the Urban Airship server.

    Note

    When updating multiple server-side values (tags, alias, time zone, quiet time), set the values first, then call updateRegistration. Batching these calls improves performance.

    Declaration

    Objective-C

    - (void)addTag:(nonnull NSString *)tag;

    Swift

    func addTag(_ tag: String)

    Parameters

    tag

    Tag to be added

  • Adds a group of tags to the current list of device tags. To update the server, make all of your changes, then call updateRegistration.

    Note

    When updating multiple server-side values (tags, alias, time zone, quiet time), set the values first, then call updateRegistration. Batching these calls improves performance.

    Declaration

    Objective-C

    - (void)addTags:(nonnull NSArray<NSString *> *)tags;

    Swift

    func addTags(_ tags: [String])

    Parameters

    tags

    Array of new tags

  • Removes a tag from the current tag list. To update the server, make all of your changes, then call updateRegistration.

    Note

    When updating multiple server-side values (tags, alias, time zone, quiet time), set the values first, then call updateRegistration. Batching these calls improves performance.

    Declaration

    Objective-C

    - (void)removeTag:(nonnull NSString *)tag;

    Swift

    func removeTag(_ tag: String)

    Parameters

    tag

    Tag to be removed

  • Removes a group of tags from a device. To update the server, make all of your changes, then call updateRegistration.

    Note

    When updating multiple server-side values (tags, alias, time zone, quiet time), set the values first, then call updateRegistration. Batching these calls improves performance.

    Declaration

    Objective-C

    - (void)removeTags:(nonnull NSArray<NSString *> *)tags;

    Swift

    func removeTags(_ tags: [String])

    Parameters

    tags

    Array of tags to be removed

  • Add tags to channel tag groups. To update the server, make all of your changes, then call updateRegistration.

    Declaration

    Objective-C

    - (void)addTags:(nonnull NSArray<NSString *> *)tags
              group:(nonnull NSString *)tagGroupID;

    Swift

    func addTags(_ tags: [String], group tagGroupID: String)

    Parameters

    tags

    Array of tags to add.

    tagGroupID

    Tag group ID string.

  • Removes tags from channel tag groups. To update the server, make all of your changes, then call updateRegistration.

    Declaration

    Objective-C

    - (void)removeTags:(nonnull NSArray<NSString *> *)tags
                 group:(nonnull NSString *)tagGroupID;

    Swift

    func removeTags(_ tags: [String], group tagGroupID: String)

    Parameters

    tags

    Array of tags to remove.

    tagGroupID

    Tag group ID string.

  • Sets tags for channel tag groups. To update the server, make all of your changes, then call updateRegistration.

    Declaration

    Objective-C

    - (void)setTags:(nonnull NSArray<NSString *> *)tags
              group:(nonnull NSString *)tagGroupID;

    Swift

    func setTags(_ tags: [String], group tagGroupID: String)

    Parameters

    tags

    Array of tags to set.

    tagGroupID

    Tag group ID string.

  • Quiet time settings for this device.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSDictionary *quietTime;

    Swift

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

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) NSTimeZone *_Nonnull timeZone;

    Swift

    var timeZone: TimeZone { get set }
  • Enables/Disables quiet time

    Declaration

    Objective-C

    @property (getter=isQuietTimeEnabled, assign, readwrite, nonatomic)
        BOOL quietTimeEnabled;

    Swift

    var isQuietTimeEnabled: 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 methods for more information.

    Declaration

    Objective-C

    - (void)setQuietTimeStartHour:(NSUInteger)startHour
                      startMinute:(NSUInteger)startMinute
                          endHour:(NSUInteger)endHour
                        endMinute:(NSUInteger)endMinute;

    Swift

    func setQuietTimeStartHour(_ startHour: UInt, startMinute: UInt, endHour: UInt, endMinute: UInt)

    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.

  • Enables channel creation if channelCreationDelayEnabled was set to YES in the config.

    Declaration

    Objective-C

    - (void)enableChannelCreation;

    Swift

    func enableChannelCreation()
  • 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

    Objective-C

    - (void)updateRegistration;

    Swift

    func updateRegistration()