AVPush Class Reference
Inherits from | NSObject |
---|---|
Declared in | AVPush.h |
Overview
A class which defines a push notification that can be sent from a client device.
The preferred way of modifying or retrieving channel subscriptions is to use the AVInstallation class, instead of the class methods in AVPush.
This class is currently for iOS only. LeanCloud does not handle Push Notifications to LeanCloud applications running on OS X. Push Notifications can be sent from OS X applications via Cloud Code or the REST API to push-enabled devices (e.g. iOS or Android).
Creating a Push Notification
+ push
创建一个 AVPush 对象
+ (instancetype)push
Return Value
AVPush 对象
Discussion
创建一个 AVPush 对象
Declared In
AVPush.h
+ setProductionMode:
Set call what production mode’s cloud code
+ (void)setProductionMode:(BOOL)isProduction
Parameters
isProduction |
the production mode or test mode |
---|
Discussion
Set call what production mode’s cloud code
Declared In
AVPush.h
Configuring a Push Notification
– setChannel:
Sets the channel on which this push notification will be sent.
- (void)setChannel:(NSString *)channel
Parameters
channel |
The channel to set for this push. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|
Discussion
Sets the channel on which this push notification will be sent.
Declared In
AVPush.h
– setChannels:
Sets the array of channels on which this push notification will be sent.
- (void)setChannels:(NSArray *)channels
Parameters
channels |
The array of channels to set for this push. Each channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|
Discussion
Sets the array of channels on which this push notification will be sent.
Declared In
AVPush.h
– setQuery:
Sets an installation query to which this push notification will be sent. The query should be created via [AVInstallation query] and should not specify a skip, limit, or order.
- (void)setQuery:(AVQuery *)query
Parameters
query |
The installation query to set for this push. |
---|
Discussion
Sets an installation query to which this push notification will be sent. The query should be created via [AVInstallation query] and should not specify a skip, limit, or order.
Declared In
AVPush.h
– setMessage:
Sets an alert message for this push notification. This will overwrite any data specified in setData.
- (void)setMessage:(NSString *)message
Parameters
message |
The message to send in this push. |
---|
Discussion
Sets an alert message for this push notification. This will overwrite any data specified in setData.
Declared In
AVPush.h
– setData:
Sets an arbitrary data payload for this push notification. See the guide for information about the dictionary structure. This will overwrite any data specified in setMessage.
- (void)setData:(NSDictionary *)data
Parameters
data |
The data to send in this push. |
---|
Discussion
Sets an arbitrary data payload for this push notification. See the guide for information about the dictionary structure. This will overwrite any data specified in setMessage.
Declared In
AVPush.h
– expireAtDate:
Sets the expiration time for this notification. The notification will be sent to devices which are either online at the time the notification is sent, or which come online before the expiration time is reached. Because device clocks are not guaranteed to be accurate, most applications should instead use expireAfterTimeInterval.
- (void)expireAtDate:(NSDate *)date
Parameters
date |
The time at which the notification should expire. |
---|
Discussion
Sets the expiration time for this notification. The notification will be sent to devices which are either online at the time the notification is sent, or which come online before the expiration time is reached. Because device clocks are not guaranteed to be accurate, most applications should instead use expireAfterTimeInterval.
Declared In
AVPush.h
– expireAfterTimeInterval:
Sets the time interval after which this notification should expire. This notification will be sent to devices which are either online at the time the notification is sent, or which come online within the given time interval of the notification being received by LeanCloud server. An interval which is less than or equal to zero indicates that the message should only be sent to devices which are currently online.
- (void)expireAfterTimeInterval:(NSTimeInterval)timeInterval
Parameters
timeInterval |
The interval after which the notification should expire. |
---|
Discussion
Sets the time interval after which this notification should expire. This notification will be sent to devices which are either online at the time the notification is sent, or which come online within the given time interval of the notification being received by LeanCloud server. An interval which is less than or equal to zero indicates that the message should only be sent to devices which are currently online.
Declared In
AVPush.h
– clearExpiration
Clears both expiration values, indicating that the notification should never expire.
- (void)clearExpiration
Discussion
Clears both expiration values, indicating that the notification should never expire.
Declared In
AVPush.h
Sending Push Notifications
+ sendPushMessageToChannel:withMessage:error:
Send a push message to a channel.
+ (BOOL)sendPushMessageToChannel:(NSString *)channel withMessage:(NSString *)message error:(NSError **)error
Parameters
channel |
The channel to send to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
message |
The message to send. |
error |
Pointer to an NSError that will be set if necessary. |
Return Value
whether the send succeeded.
Discussion
Send a push message to a channel.
Declared In
AVPush.h
+ sendPushMessageToChannelInBackground:withMessage:
Asynchronously send a push message to a channel.
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel withMessage:(NSString *)message
Parameters
channel |
The channel to send to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
message |
The message to send. |
Discussion
Asynchronously send a push message to a channel.
Declared In
AVPush.h
+ sendPushMessageToChannelInBackground:withMessage:block:
Asynchronously sends a push message to a channel and calls the given block.
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel withMessage:(NSString *)message block:(AVBooleanResultBlock)block
Parameters
channel |
The channel to send to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
message |
The message to send. |
block |
The block to execute. The block should have the following argument signature: (BOOL succeeded, NSError *error) |
Discussion
Asynchronously sends a push message to a channel and calls the given block.
Declared In
AVPush.h
+ sendPushMessageToChannelInBackground:withMessage:target:selector:
Asynchronously send a push message to a channel.
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel withMessage:(NSString *)message target:(id)target selector:(SEL)selector
Parameters
channel |
The channel to send to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
message |
The message to send. |
target |
The object to call selector on. |
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(NSNumber )result error:(NSError )error. error will be nil on success and set if there was an error. [result boolValue] will tell you whether the call succeeded or not. |
Discussion
Asynchronously send a push message to a channel.
Declared In
AVPush.h
+ sendPushMessageToQuery:withMessage:error:
Send a push message to a query.
+ (BOOL)sendPushMessageToQuery:(AVQuery *)query withMessage:(NSString *)message error:(NSError **)error
Parameters
query |
The query to send to. The query must be a AVInstallation query created with [AVInstallation query]. |
---|---|
message |
The message to send. |
error |
Pointer to an NSError that will be set if necessary. |
Return Value
whether the send succeeded.
Discussion
Send a push message to a query.
Declared In
AVPush.h
+ sendPushMessageToQueryInBackground:withMessage:
Asynchronously send a push message to a query.
+ (void)sendPushMessageToQueryInBackground:(AVQuery *)query withMessage:(NSString *)message
Parameters
query |
The query to send to. The query must be a AVInstallation query created with [AVInstallation query]. |
---|---|
message |
The message to send. |
Discussion
Asynchronously send a push message to a query.
Declared In
AVPush.h
+ sendPushMessageToQueryInBackground:withMessage:block:
Asynchronously sends a push message to a query and calls the given block.
+ (void)sendPushMessageToQueryInBackground:(AVQuery *)query withMessage:(NSString *)message block:(AVBooleanResultBlock)block
Parameters
query |
The query to send to. The query must be a AVInstallation query created with [AVInstallation query]. |
---|---|
message |
The message to send. |
block |
The block to execute. The block should have the following argument signature: (BOOL succeeded, NSError *error) |
Discussion
Asynchronously sends a push message to a query and calls the given block.
Declared In
AVPush.h
– sendPushAndThrowsWithError:
An alias of [AVPush sendPush:]
methods that supports Swift exception.
@seealso [AVPush sendPush:]
- (BOOL)sendPushAndThrowsWithError:(NSError **)error
Discussion
An alias of [AVPush sendPush:]
methods that supports Swift exception.
@seealso [AVPush sendPush:]
Declared In
AVPush.h
– sendPushInBackgroundWithBlock:
Asynchronously send this push message and executes the given callback block.
- (void)sendPushInBackgroundWithBlock:(AVBooleanResultBlock)block
Parameters
block |
The block to execute. The block should have the following argument signature: (BOOL succeeded, NSError *error) |
---|
Discussion
Asynchronously send this push message and executes the given callback block.
Declared In
AVPush.h
– sendPushInBackgroundWithTarget:selector:
Asynchronously send this push message and calls the given callback.
- (void)sendPushInBackgroundWithTarget:(id)target selector:(SEL)selector
Parameters
target |
The object to call selector on. |
---|---|
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(NSNumber )result error:(NSError )error. error will be nil on success and set if there was an error. [result boolValue] will tell you whether the call succeeded or not. |
Discussion
Asynchronously send this push message and calls the given callback.
Declared In
AVPush.h
+ sendPushDataToChannel:withData:error:
Send a push message with arbitrary data to a channel. See the guide for information about the dictionary structure.
+ (BOOL)sendPushDataToChannel:(NSString *)channel withData:(NSDictionary *)data error:(NSError **)error
Parameters
channel |
The channel to send to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
data |
The data to send. |
error |
Pointer to an NSError that will be set if necessary. |
Return Value
whether the send succeeded.
Discussion
Send a push message with arbitrary data to a channel. See the guide for information about the dictionary structure.
Declared In
AVPush.h
+ sendPushDataToChannelInBackground:withData:
Asynchronously send a push message with arbitrary data to a channel. See the guide for information about the dictionary structure.
+ (void)sendPushDataToChannelInBackground:(NSString *)channel withData:(NSDictionary *)data
Parameters
channel |
The channel to send to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
data |
The data to send. |
Discussion
Asynchronously send a push message with arbitrary data to a channel. See the guide for information about the dictionary structure.
Declared In
AVPush.h
+ sendPushDataToChannelInBackground:withData:block:
Asynchronously sends a push message with arbitrary data to a channel and calls the given block. See the guide for information about the dictionary structure.
+ (void)sendPushDataToChannelInBackground:(NSString *)channel withData:(NSDictionary *)data block:(AVBooleanResultBlock)block
Parameters
channel |
The channel to send to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
data |
The data to send. |
block |
The block to execute. The block should have the following argument signature: (BOOL succeeded, NSError *error) |
Discussion
Asynchronously sends a push message with arbitrary data to a channel and calls the given block. See the guide for information about the dictionary structure.
Declared In
AVPush.h
+ sendPushDataToChannelInBackground:withData:target:selector:
Asynchronously send a push message with arbitrary data to a channel. See the guide for information about the dictionary structure.
+ (void)sendPushDataToChannelInBackground:(NSString *)channel withData:(NSDictionary *)data target:(id)target selector:(SEL)selector
Parameters
channel |
The channel to send to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
data |
The data to send. |
target |
The object to call selector on. |
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(NSNumber )result error:(NSError )error. error will be nil on success and set if there was an error. [result boolValue] will tell you whether the call succeeded or not. |
Discussion
Asynchronously send a push message with arbitrary data to a channel. See the guide for information about the dictionary structure.
Declared In
AVPush.h
+ sendPushDataToQuery:withData:error:
Send a push message with arbitrary data to a query. See the guide for information about the dictionary structure.
+ (BOOL)sendPushDataToQuery:(AVQuery *)query withData:(NSDictionary *)data error:(NSError **)error
Parameters
query |
The query to send to. The query must be a AVInstallation query created with [AVInstallation query]. |
---|---|
data |
The data to send. |
error |
Pointer to an NSError that will be set if necessary. |
Return Value
whether the send succeeded.
Discussion
Send a push message with arbitrary data to a query. See the guide for information about the dictionary structure.
Declared In
AVPush.h
+ sendPushDataToQueryInBackground:withData:
Asynchronously send a push message with arbitrary data to a query. See the guide for information about the dictionary structure.
+ (void)sendPushDataToQueryInBackground:(AVQuery *)query withData:(NSDictionary *)data
Parameters
query |
The query to send to. The query must be a AVInstallation query created with [AVInstallation query]. |
---|---|
data |
The data to send. |
Discussion
Asynchronously send a push message with arbitrary data to a query. See the guide for information about the dictionary structure.
Declared In
AVPush.h
+ sendPushDataToQueryInBackground:withData:block:
Asynchronously sends a push message with arbitrary data to a query and calls the given block. See the guide for information about the dictionary structure.
+ (void)sendPushDataToQueryInBackground:(AVQuery *)query withData:(NSDictionary *)data block:(AVBooleanResultBlock)block
Parameters
query |
The query to send to. The query must be a AVInstallation query created with [AVInstallation query]. |
---|---|
data |
The data to send. |
block |
The block to execute. The block should have the following argument signature: (BOOL succeeded, NSError *error) |
Discussion
Asynchronously sends a push message with arbitrary data to a query and calls the given block. See the guide for information about the dictionary structure.
Declared In
AVPush.h
Handling Notifications
+ getSubscribedChannels:
Get all the channels that this device is subscribed to.
+ (nullable NSSet *)getSubscribedChannels:(NSError **)error
Parameters
error |
Pointer to an NSError that will be set if necessary. |
---|
Return Value
an NSSet containing all the channel names this device is subscribed to.
Discussion
Get all the channels that this device is subscribed to.
Declared In
AVPush.h
+ getSubscribedChannelsAndThrowsWithError:
An alias of [AVPush getSubscribedChannels:]
methods that supports Swift exception.
@seealso [AVPush getSubscribedChannels:]
+ (nullable NSSet *)getSubscribedChannelsAndThrowsWithError:(NSError **)error
Discussion
An alias of [AVPush getSubscribedChannels:]
methods that supports Swift exception.
@seealso [AVPush getSubscribedChannels:]
Declared In
AVPush.h
+ getSubscribedChannelsInBackgroundWithBlock:
Get all the channels that this device is subscribed to.
+ (void)getSubscribedChannelsInBackgroundWithBlock:(AVSetResultBlock)block
Parameters
block |
The block to execute. The block should have the following argument signature: (NSSet channels, NSError error) |
---|
Discussion
Get all the channels that this device is subscribed to.
Declared In
AVPush.h
+ getSubscribedChannelsInBackgroundWithTarget:selector:
Asynchronously get all the channels that this device is subscribed to.
+ (void)getSubscribedChannelsInBackgroundWithTarget:(id)target selector:(SEL)selector
Parameters
target |
The object to call selector on. |
---|---|
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(NSSet )result error:(NSError )error. error will be nil on success and set if there was an error. |
Discussion
Asynchronously get all the channels that this device is subscribed to.
Declared In
AVPush.h
+ subscribeToChannel:error:
Subscribes the device to a channel of push notifications.
+ (BOOL)subscribeToChannel:(NSString *)channel error:(NSError **)error
Parameters
channel |
The channel to subscribe to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
error |
Pointer to an NSError that will be set if necessary. |
Return Value
whether the subscribe succeeded.
Discussion
Subscribes the device to a channel of push notifications.
Declared In
AVPush.h
+ subscribeToChannelInBackground:
Asynchronously subscribes the device to a channel of push notifications.
+ (void)subscribeToChannelInBackground:(NSString *)channel
Parameters
channel |
The channel to subscribe to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|
Discussion
Asynchronously subscribes the device to a channel of push notifications.
Declared In
AVPush.h
+ subscribeToChannelInBackground:block:
Asynchronously subscribes the device to a channel of push notifications and calls the given block.
+ (void)subscribeToChannelInBackground:(NSString *)channel block:(AVBooleanResultBlock)block
Parameters
channel |
The channel to subscribe to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
block |
The block to execute. The block should have the following argument signature: (BOOL succeeded, NSError *error) |
Discussion
Asynchronously subscribes the device to a channel of push notifications and calls the given block.
Declared In
AVPush.h
+ subscribeToChannelInBackground:target:selector:
Asynchronously subscribes the device to a channel of push notifications and calls the given callback.
+ (void)subscribeToChannelInBackground:(NSString *)channel target:(id)target selector:(SEL)selector
Parameters
channel |
The channel to subscribe to. The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
---|---|
target |
The object to call selector on. |
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(NSNumber )result error:(NSError )error. error will be nil on success and set if there was an error. [result boolValue] will tell you whether the call succeeded or not. |
Discussion
Asynchronously subscribes the device to a channel of push notifications and calls the given callback.
Declared In
AVPush.h
+ unsubscribeFromChannel:error:
Unsubscribes the device to a channel of push notifications.
+ (BOOL)unsubscribeFromChannel:(NSString *)channel error:(NSError **)error
Parameters
channel |
The channel to unsubscribe from. |
---|---|
error |
Pointer to an NSError that will be set if necessary. |
Return Value
whether the unsubscribe succeeded.
Discussion
Unsubscribes the device to a channel of push notifications.
Declared In
AVPush.h
+ unsubscribeFromChannelInBackground:
Asynchronously unsubscribes the device from a channel of push notifications.
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel
Parameters
channel |
The channel to unsubscribe from. |
---|
Discussion
Asynchronously unsubscribes the device from a channel of push notifications.
Declared In
AVPush.h
+ unsubscribeFromChannelInBackground:block:
Asynchronously unsubscribes the device from a channel of push notifications and calls the given block.
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel block:(AVBooleanResultBlock)block
Parameters
channel |
The channel to unsubscribe from. |
---|---|
block |
The block to execute. The block should have the following argument signature: (BOOL succeeded, NSError *error) |
Discussion
Asynchronously unsubscribes the device from a channel of push notifications and calls the given block.
Declared In
AVPush.h
+ unsubscribeFromChannelInBackground:target:selector:
Asynchronously unsubscribes the device from a channel of push notifications and calls the given callback.
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel target:(id)target selector:(SEL)selector
Parameters
channel |
The channel to unsubscribe from. |
---|---|
target |
The object to call selector on. |
selector |
The selector to call. It should have the following signature: (void)callbackWithResult:(NSNumber )result error:(NSError )error. error will be nil on success and set if there was an error. [result boolValue] will tell you whether the call succeeded or not. |
Discussion
Asynchronously unsubscribes the device from a channel of push notifications and calls the given callback.
Declared In
AVPush.h