UAPush
@interface UAPush : UAComponent
This singleton provides an interface to the functionality provided by the Airship iOS Push API.
-
Enables/disables background remote notifications on this device through Airship. Defaults to
YES
.Declaration
Objective-C
@property (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 (nonatomic) BOOL backgroundPushNotificationsEnabledByDefault;
Swift
var backgroundPushNotificationsEnabledByDefault: Bool { get set }
-
Enables/disables user notifications on this device through Airship. Defaults to
NO
. Once set toYES
, the user will be prompted for remote notifications.Declaration
Objective-C
@property (nonatomic) BOOL userPushNotificationsEnabled;
Swift
var userPushNotificationsEnabled: Bool { get set }
-
Enables/disables sending the device token during channel registration. Defaults to
UAirship.isDataCollectionEnabled
. If set toNO
, the app will not be able to receive push notifications.Declaration
Objective-C
@property (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 (nonatomic) BOOL userPushNotificationsEnabledByDefault;
Swift
var userPushNotificationsEnabledByDefault: Bool { get set }
-
Enables/disables extended App Clip user notifications on this device through Airship. Defaults to
NO
. Once set toYES
, the user will be prompted for remote notifications.Warning
This property should only be set in an App Clip context. In all other cases, setting it to any value will have no effect. If userPushNotificationsEnabled is set to ‘NO’ , setting this property will have no effect.Declaration
Objective-C
@property (nonatomic) BOOL extendedPushNotificationPermissionEnabled;
Swift
var extendedPushNotificationPermissionEnabled: Bool { get set }
-
The device token for this device, as a hex string.
Declaration
Objective-C
@property (nonatomic, copy, readonly, nullable) NSString *deviceToken;
Swift
var deviceToken: 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 (nonatomic) UANotificationOptions notificationOptions;
Swift
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
Objective-C
@property (nonatomic, copy) 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 Airship provided categories.Declaration
Objective-C
@property (nonatomic, readonly) NSSet<UANotificationCategory *> *_Nonnull combinedCategories;
Swift
var combinedCategories: Set<AnyHashable> { 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
Objective-C
@property (nonatomic) BOOL requireAuthorizationForDefaultCategories;
Swift
var requireAuthorizationForDefaultCategories: Bool { get set }
-
Set a delegate that implements the UAPushNotificationDelegate protocol.
Declaration
Objective-C
@property (nonatomic, weak, nullable) id<UAPushNotificationDelegate> pushNotificationDelegate;
Swift
weak var pushNotificationDelegate: UAPushNotificationDelegate? { get set }
-
Set a delegate that implements the UARegistrationDelegate protocol.
Declaration
Objective-C
@property (nonatomic, weak, nullable) id<UARegistrationDelegate> registrationDelegate;
Swift
weak var registrationDelegate: UARegistrationDelegate? { get set }
-
Notification response that launched the application.
Declaration
Objective-C
@property (nonatomic, strong, readonly, 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 (nonatomic, readonly) UAAuthorizedNotificationSettings authorizedNotificationSettings;
Swift
var authorizedNotificationSettings: UAAuthorizedNotificationSettings { get }
-
The current authorization status.
Declaration
Objective-C
@property (nonatomic, readonly) UAAuthorizationStatus authorizationStatus;
Swift
var authorizationStatus: UAAuthorizationStatus { get }
-
Indicates whether the user has been prompted for notifications or not.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL userPromptedForNotifications;
Swift
var userPromptedForNotifications: Bool { get }
-
The default presentation options to use for foreground notifications.
Declaration
Objective-C
@property (nonatomic) UNNotificationPresentationOptions defaultPresentationOptions;
Swift
var defaultPresentationOptions: UNNotificationPresentationOptions { get set }
-
The current badge number used by the device and on the Airship server.
Note
This property must be accessed on the main thread.Declaration
Objective-C
@property (nonatomic) NSInteger badgeNumber;
Swift
var badgeNumber: Int { get set }
-
Toggle the Airship auto-badge feature. Defaults to
NO
If enabled, this will update the badge number stored by Airship every time the app is started or foregrounded.Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isAutobadgeEnabled) BOOL autobadgeEnabled;
Swift
var isAutobadgeEnabled: Bool { get set }
-
Resets the badge to zero (0) on both the device and on 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()
-
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 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.
-
Quiet time settings for this device.
Declaration
Objective-C
@property (nonatomic, copy, readonly, 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 (nonatomic, strong) NSTimeZone *_Nonnull timeZone;
Swift
var timeZone: TimeZone { get set }
-
Enables/Disables quiet time
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isQuietTimeEnabled) 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
andupdateRegistration
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.
-
Registers or updates the current registration with an API call. If push notifications are not enabled, this unregisters the device token.
Add a
UARegistrationDelegate
toUAPush
to receive success and failure callbacks.Declaration
Objective-C
- (void)updateRegistration;
Swift
func updateRegistration()