public class AVPush extends Object
The AVPush is a local representation of data that can be sent as a push notification.
The typical workflow for sending a push notification from the client is to construct a new AVPush, use the setter functions to fill it with data, and then use AVPush.sendInBackground() to send it.
| Constructor and Description |
|---|
AVPush()
Creates a new push notification.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearExpiration()
Clears both expiration values, indicating that the notification should never expire.
|
Set<String> |
getChannelSet() |
long |
getExpirationTime() |
long |
getExpirationTimeInterval() |
com.avos.avoscloud.AVObject |
getNotification()
返回推送后创建的_Notification对象。
|
boolean |
getProductionMode() |
Map<String,Object> |
getPushData() |
Date |
getPushDate() |
com.avos.avoscloud.AVQuery |
getPushQuery() |
Set<String> |
getPushTarget() |
void |
send()
Sends this push notification while blocking this thread until the push notification has
successfully reached the AVOSCloud servers.
|
static void |
sendDataInBackground(org.json.JSONObject data,
com.avos.avoscloud.AVQuery<? extends com.avos.avoscloud.AVObject> query,
com.avos.avoscloud.SendCallback callback)
A helper method to concisely send a push to a query.
|
void |
sendInBackground()
Sends this push notification in a background thread.
|
void |
sendInBackground(com.avos.avoscloud.SendCallback callback)
Sends this push notification in a background thread.
|
static void |
sendMessageInBackground(String message,
com.avos.avoscloud.AVQuery<? extends com.avos.avoscloud.AVObject> query)
A helper method to concisely send a push message to a query.
|
static void |
sendMessageInBackground(String message,
com.avos.avoscloud.AVQuery<? extends com.avos.avoscloud.AVObject> query,
com.avos.avoscloud.SendCallback callback)
A helper method to concisely send a push message to a query.
|
void |
setChannel(String channel)
Sets the channel on which this push notification will be sent.
|
void |
setChannels(Collection<String> channels)
Sets the collection of channels on which this push notification will be sent.
|
void |
setCloudQuery(String cql)
可以通过 cql来针对push进行筛选
请注意cql 的主体应该是_Installation表
请在设置cql的同时,不要设置pushTarget(ios,android,wp)
|
void |
setData(org.json.JSONObject data)
Sets the entire data of the push message.
|
void |
setData(Map<String,Object> data)
Sets the entire data of the push message.
|
void |
setExpirationTime(long time)
Sets a UNIX epoch timestamp at which this notification should expire, in seconds (UTC).
|
void |
setExpirationTimeInterval(long timeInterval)
Sets the time interval after which this notification should expire, in seconds.
|
void |
setMessage(String message)
Sets the message that will be shown in the notification.
|
void |
setProductionMode(boolean production)
设定iOS推送是否是生产环境
|
void |
setPushDate(Date date)
Set the push date at which the push will be sent.
|
void |
setPushToAndroid(boolean pushToAndroid) |
void |
setPushToIOS(boolean pushToIOS) |
void |
setPushToWindowsPhone(boolean pushToWP) |
void |
setQuery(com.avos.avoscloud.AVQuery<? extends com.avos.avoscloud.AVObject> query)
Sets the query for this push for which this push notification will be sent.
|
public AVPush()
public com.avos.avoscloud.AVObject getNotification()
public com.avos.avoscloud.AVQuery getPushQuery()
public Date getPushDate()
public long getExpirationTime()
public long getExpirationTimeInterval()
public void clearExpiration()
public void send()
public static void sendDataInBackground(org.json.JSONObject data,
com.avos.avoscloud.AVQuery<? extends com.avos.avoscloud.AVObject> query,
com.avos.avoscloud.SendCallback callback)
AVPush push = new AVPush(); push.setData(data); push.setQuery(query); push.sendInBackground(callback);
data - The entire data of the push message. See the push guide for more details on the
data format.query - A AVInstallation query which specifies the recipients of a push.callback - callback.done(e) is called when the send completes.public void sendInBackground()
public void sendInBackground(com.avos.avoscloud.SendCallback callback)
callback - callback.done(e) is called when the send completes.public static void sendMessageInBackground(String message, com.avos.avoscloud.AVQuery<? extends com.avos.avoscloud.AVObject> query)
AVPush push = new AVPush(); push.setMessage(message); push.setQuery(query); push.sendInBackground();
message - The message that will be shown in the notification.query - A AVInstallation query which specifies the recipients of a push.public static void sendMessageInBackground(String message, com.avos.avoscloud.AVQuery<? extends com.avos.avoscloud.AVObject> query, com.avos.avoscloud.SendCallback callback)
AVPush push = new AVPush(); push.setMessage(message); push.setQuery(query); push.sendInBackground(callback);
message - The message that will be shown in the notification.query - A AVInstallation query which specifies the recipients of a push.callback - callback.done(e) is called when the send completes.public void setChannel(String channel)
channel - set push channelpublic void setChannels(Collection<String> channels)
channels - set push channelspublic void setData(Map<String,Object> data)
data - push datapublic void setData(org.json.JSONObject data)
data - push datapublic void setPushDate(Date date)
date - The push date.public void setExpirationTime(long time)
time - expire datepublic void setExpirationTimeInterval(long timeInterval)
timeInterval - expirationTimeIntervalpublic void setMessage(String message)
message - set push messagepublic void setPushToAndroid(boolean pushToAndroid)
public void setPushToIOS(boolean pushToIOS)
public void setPushToWindowsPhone(boolean pushToWP)
public void setQuery(com.avos.avoscloud.AVQuery<? extends com.avos.avoscloud.AVObject> query)
query - A query to which this push should target. This must be a AVInstallation query.public void setCloudQuery(String cql)
cql - cql for pushpublic boolean getProductionMode()
public void setProductionMode(boolean production)
production,true为生产环境,默认是true - Copyright © 2017. All rights reserved.