UAPush Class Reference
Inherits from | NSObject |
Conforms to | UAChannelRegistrarDelegate |
Declared in | UAPush.h |
Overview
This singleton provides an interface to the functionality provided by the Urban Airship iOS Push API.
Tasks
Push Notifications
-
backgroundPushNotificationsEnabled
property -
backgroundPushNotificationsEnabledByDefault
property -
userPushNotificationsEnabled
property -
pushTokenRegistrationEnabled
property -
allowUnregisteringUserNotificationTypes
property -
requireSettingsAppToDisableUserNotifications
property -
userPushNotificationsEnabledByDefault
property -
deviceToken
property -
channelID
property -
notificationTypes
property -
userNotificationTypes
property -
userNotificationCategories
property -
requireAuthorizationForDefaultCategories
property -
pushNotificationDelegate
property -
registrationDelegate
property -
launchNotification
property
Autobadge
Alias
-
alias
property
Named User
-
namedUser
property
Tags
-
tags
property -
deviceTagsEnabled
property -
channelTagRegistrationEnabled
property -
– addTag:
-
– addTags:
-
– removeTag:
-
– removeTags:
Tag Groups
Quiet Time
-
quietTime
property -
timeZone
property -
quietTimeEnabled
property -
– setQuietTimeStartHour:startMinute:endHour:endMinute:
Channel Registration
AppDelegate hooks
-
– appReceivedRemoteNotification:applicationState:
-
– appReceivedRemoteNotification:applicationState:fetchCompletionHandler:
-
– appRegisteredForRemoteNotificationsWithDeviceToken:
-
– appRegisteredUserNotificationSettings
-
– appReceivedActionWithIdentifier:notification:applicationState:completionHandler:
-
– appReceivedActionWithIdentifier:notification:responseInfo:applicationState:completionHandler:
Properties
alias
Alias for this device
@property (nonatomic, copy, nullable) NSString *alias
Declared In
UAPush.h
allowUnregisteringUserNotificationTypes
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.
@property (nonatomic, assign) BOOL allowUnregisteringUserNotificationTypes
Discussion
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
.
Declared In
UAPush.h
autobadgeEnabled
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.
@property (nonatomic, assign, getter=isAutobadgeEnabled) BOOL autobadgeEnabled
Declared In
UAPush.h
backgroundPushNotificationsEnabled
Enables/disables background remote notifications on this device through Urban Airship.
Defaults to YES
.
@property (nonatomic, assign) BOOL backgroundPushNotificationsEnabled
Declared In
UAPush.h
backgroundPushNotificationsEnabledByDefault
Sets the default value for backgroundPushNotificationsEnabled. The default is YES
.
After the backgroundPushNotificationsEnabled value has been directly set, this
value has no effect.
@property (nonatomic, assign) BOOL backgroundPushNotificationsEnabledByDefault
Declared In
UAPush.h
channelID
The channel ID for this device.
@property (nonatomic, copy, readonly, nullable) NSString *channelID
Declared In
UAPush.h
channelTagRegistrationEnabled
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.
@property (nonatomic, assign, getter=isChannelTagRegistrationEnabled) BOOL channelTagRegistrationEnabled
Discussion
Set this to NO
to prevent the device from sending any tag information to the server when using
server-side tagging. Defaults to YES
.
Declared In
UAPush.h
deviceTagsEnabled
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. (Deprecated: As of version 6.1.0. Replaced with channelTagRegistrationEnabled.)
@property (nonatomic, assign) BOOL deviceTagsEnabled
Discussion
Set this to NO
to prevent the device from sending any tag information to the server when using
server-side tagging. Defaults to YES
.
Declared In
UAPush.h
deviceToken
The device token for this device, as a hex string.
@property (nonatomic, copy, readonly, nullable) NSString *deviceToken
Declared In
UAPush.h
launchNotification
Notification that launched the application
@property (nonatomic, readonly, strong, nullable) NSDictionary *launchNotification
Declared In
UAPush.h
namedUser
Named user for this device.
@property (nonatomic, strong) UANamedUser *namedUser
Declared In
UAPush.h
notificationTypes
Notification types this app will request from APNS. Changes to this value will not take effect the next time the app registers with updateRegistration. (Deprecated: As of version 5.0. Replaced with userNotificationTypes.)
@property (nonatomic, assign) UIRemoteNotificationType notificationTypes
Discussion
Defaults to alert, sound and badge.
Declared In
UAPush.h
pushNotificationDelegate
Set a delegate that implements the UAPushNotificationDelegate protocol.
@property (nonatomic, weak, nullable) id<UAPushNotificationDelegate> pushNotificationDelegate
Declared In
UAPush.h
pushTokenRegistrationEnabled
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.
@property (nonatomic, assign) BOOL pushTokenRegistrationEnabled
Declared In
UAPush.h
quietTime
Quiet time settings for this device.
@property (nonatomic, copy, readonly, nullable) NSDictionary *quietTime
Declared In
UAPush.h
quietTimeEnabled
Enables/Disables quiet time
@property (nonatomic, assign, getter=isQuietTimeEnabled) BOOL quietTimeEnabled
Declared In
UAPush.h
registrationDelegate
Set a delegate that implements the UARegistrationDelegate protocol.
@property (nonatomic, weak, nullable) id<UARegistrationDelegate> registrationDelegate
Declared In
UAPush.h
requireAuthorizationForDefaultCategories
Sets authorization required for the default Urban Airship categories. Only applies to background user notification actions.
@property (nonatomic, assign) BOOL requireAuthorizationForDefaultCategories
Discussion
Changes to this value will not take effect the next time the app registers with updateRegistration.
Declared In
UAPush.h
requireSettingsAppToDisableUserNotifications
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.
@property (nonatomic, assign) BOOL requireSettingsAppToDisableUserNotifications
Discussion
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]]
Declared In
UAPush.h
tags
Tags for this device.
@property (nonatomic, copy) NSArray<NSString*> *tags
Declared In
UAPush.h
timeZone
Time Zone for quiet time. If the time zone is not set, the current local time zone is returned.
@property (nonatomic, strong) NSTimeZone *timeZone
Declared In
UAPush.h
userNotificationCategories
Custom user notification categories. Urban Airship default user notification categories will be unaffected by this field.
@property (nonatomic, strong) NSSet *userNotificationCategories
Discussion
Changes to this value will not take effect the next time the app registers with updateRegistration.
Declared In
UAPush.h
userNotificationTypes
User Notification types this app will request from APNS. Changes to this value will not take effect the next time the app registers with updateRegistration.
@property (nonatomic, assign) UIUserNotificationType userNotificationTypes
Discussion
Defaults to alert, sound and badge.
Declared In
UAPush.h
userPushNotificationsEnabled
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.
@property (nonatomic, assign) BOOL userPushNotificationsEnabled
Discussion
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.
Declared In
UAPush.h
userPushNotificationsEnabledByDefault
Sets the default value for userPushNotificationsEnabled. The default is NO
.
After the userPushNotificationsEnabled value has been directly set, this value
has no effect.
@property (nonatomic, assign) BOOL userPushNotificationsEnabledByDefault
Declared In
UAPush.h
Instance Methods
addTag:
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.
- (void)addTag:(NSString *)tag
Parameters
- tag
Tag to be added
Discussion
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.
Declared In
UAPush.h
addTags:
Adds a group of tags to the current list of device tags. To update the server, make all of your
changes, then call updateRegistration
.
- (void)addTags:(NSArray<NSString*> *)tags
Parameters
- tags
Array of new tags
Discussion
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.
Declared In
UAPush.h
addTags:group:
Add tags to channel tag groups. To update the server,
make all of your changes, then call updateRegistration
.
- (void)addTags:(NSArray<NSString*> *)tags group:(NSString *)tagGroupID
Declared In
UAPush.h
appReceivedActionWithIdentifier:notification:applicationState:completionHandler:
Handle interactive notification actions.
- (void)appReceivedActionWithIdentifier:(NSString *)identifier notification:(NSDictionary *)notification applicationState:(UIApplicationState)state completionHandler:(void ( ^ ) ( ))completionHandler
Parameters
- identifier
The identifier of the button that was triggered.
- notification
The notification payload, as passed to your application delegate.
- state
The application state at the time the notification was received.
- completionHandler
The completion handler.
Declared In
UAPush.h
appReceivedActionWithIdentifier:notification:responseInfo:applicationState:completionHandler:
Handle interactive notification actions with response info.
- (void)appReceivedActionWithIdentifier:(NSString *)identifier notification:(NSDictionary *)notification responseInfo:(nullable NSDictionary *)responseInfo applicationState:(UIApplicationState)state completionHandler:(void ( ^ ) ( ))completionHandler
Parameters
- identifier
The identifier of the button that was triggered.
- notification
The notification payload, as passed to your application delegate.
- responseInfo
The response info, as passed to your application delegate.
- state
The application state at the time the notification was received.
- completionHandler
The completion handler.
Declared In
UAPush.h
appReceivedRemoteNotification:applicationState:
Handle incoming push notifications. This method will record push conversions, parse the notification and call the appropriate methods on your delegate.
- (void)appReceivedRemoteNotification:(NSDictionary *)notification applicationState:(UIApplicationState)state
Parameters
- notification
The notification payload, as passed to your application delegate.
- state
The application state at the time the notification was received.
Declared In
UAPush.h
appReceivedRemoteNotification:applicationState:fetchCompletionHandler:
Handle incoming push notifications. This method will record push conversions, parse the notification and call the appropriate methods on your delegate.
- (void)appReceivedRemoteNotification:(NSDictionary *)notification applicationState:(UIApplicationState)state fetchCompletionHandler:(nullable void ( ^ ) ( UIBackgroundFetchResult result ))completionHandler
Parameters
- notification
The notification payload, as passed to your application delegate.
- state
The application state at the time the notification was received.
- completionHandler
Should be called with a UIBackgroundFetchResult as soon as possible, so the system can accurately estimate its power and data cost.
Declared In
UAPush.h
appRegisteredForRemoteNotificationsWithDeviceToken:
Handle device token registration. Associates the token with the channel and update the channel registration.
- (void)appRegisteredForRemoteNotificationsWithDeviceToken:(NSData *)token
Parameters
- token
The device token to register.
Discussion
Add a UARegistrationDelegate
to UAPush
to received success and failure callbacks.
Declared In
UAPush.h
appRegisteredUserNotificationSettings
Handles user notification settings registration.
- (void)appRegisteredUserNotificationSettings
Declared In
UAPush.h
currentEnabledNotificationTypes
Gets the current enabled notification types.
- (UIUserNotificationType)currentEnabledNotificationTypes
Return Value
The current enabled notification types.
Declared In
UAPush.h
enableChannelCreation
Enables channel creation if channelCreationDelayEnabled was set to YES
in the config.
- (void)enableChannelCreation
Declared In
UAPush.h
removeTag:
Removes a tag from the current tag list. To update the server, make all of your changes, then call
updateRegistration
.
- (void)removeTag:(NSString *)tag
Parameters
- tag
Tag to be removed
Discussion
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.
Declared In
UAPush.h
removeTags:
Removes a group of tags from a device. To update the server, make all of your changes, then call
updateRegistration
.
- (void)removeTags:(NSArray<NSString*> *)tags
Parameters
- tags
Array of tags to be removed
Discussion
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.
Declared In
UAPush.h
removeTags:group:
Removes tags from channel tag groups. To update the server,
make all of your changes, then call updateRegistration
.
- (void)removeTags:(NSArray<NSString*> *)tags group:(NSString *)tagGroupID
Declared In
UAPush.h
resetBadge
Resets the badge to zero (0) on both the device and on Urban Airships servers. This is a
convenience method for setBadgeNumber:0
.
- (void)resetBadge
Declared In
UAPush.h
setBadgeNumber:
Sets the badge number on the device and on the Urban Airship server.
- (void)setBadgeNumber:(NSInteger)badgeNumber
Parameters
- badgeNumber
The new badge number
Declared In
UAPush.h
setQuietTimeStartHour:startMinute:endHour:endMinute:
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’.
- (void)setQuietTimeStartHour:(NSUInteger)startHour startMinute:(NSUInteger)startMinute endHour:(NSUInteger)endHour endMinute:(NSUInteger)endMinute
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.
Discussion
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.
Declared In
UAPush.h
updateRegistration
Registers or updates the current registration with an API call. If push notifications are not enabled, this unregisters the device token.
- (void)updateRegistration
Discussion
Add a UARegistrationDelegate
to UAPush
to receive success and failure callbacks.
Declared In
UAPush.h