UAPush

@interface UAPush : NSObject

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.

    On iOS 8+, we recommend that you do not change this value to NO and instead direct users to the iOS Settings App. As such, the transition from YES to NO is disabled by default on iOS 8+. Please see requireSettingsAppToDisableUserNotifications for details.

    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 }
  • This setting controls the underlying behavior of the SDK when user notifications are disabled. When set to NO and user notifications are disabled with the userPushNotificationsEnabled property, this SDK will mark the device as opted-out on the Urban Airship server but the OS-level settings will still show this device as able to receive user notifications.

    This is a temporary flag to work around an issue in iOS 8 where unregistering user notification types may prevent the device from being able to register with other types without a device restart. It will be removed once the issue is addressed in iOS 8.

    This setting defaults to YES due to the new flag requireSettingsAppToDisableUserNotifications. To enable UA SDK 5 behavior, set this flag and requireSettingsAppToDisableUserNotifications to NO.

    Declaration

    Objective-C

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

    Swift

    var allowUnregisteringUserNotificationTypes: Bool { get set }
  • This setting controls the behavior of the userPushNotificationsEnabled setting. If set to YES, the application will not be allowed to set userPushNotificationsEnabled to NO, and instead, the user should be directed to the iOS Settings app via the UIApplicationOpenSettingsURLString URL constant. The iOS Settings app is the preferred method of disabling user notifications as of iOS 8.

    The setting defaults to YES on iOS 8+. Changing this setting to NO could allow notifications with user-visible components (badge, alert, or sound) to be processed by the OS if the notification also has a background content-available flag in the aps section of the notification.

    On versions of iOS prior to iOS 8, this flag will always return NO. Those iOS versions do not allow linking to the Settings app and are unaffected by the opt-out after opt-in bug.

    To open the iOS Settings app directly to your application’s settings: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]

    Declaration

    Objective-C

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

    Swift

    var requireSettingsAppToDisableUserNotifications: 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
  • 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
  • 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 options.

    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;

    Swift

    var defaultPresentationOptions: Int32 { get set }
  • 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.

    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.

    Declaration

    Objective-C

    - (void)resetBadge;

    Swift

    func resetBadge()
  • Alias for this device

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *alias;

    Swift

    var alias: String? { get set }
  • 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 }
  • 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()