|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface PushService
The push notification service.
| Nested Class Summary | |
|---|---|
static class |
PushService.TokenAndType
|
static class |
PushService.TokenType
|
| Method Summary | |
|---|---|
void |
broadcastPush(int badge,
String sound,
String alert)
Deprecated. use broadcastPush(java.util.Map) instead. this method only broadcasts to iOS devices |
void |
broadcastPush(Map<String,String> pairs)
broadcast a push to all devices registered to the current application. |
Map<PushService.TokenAndType,Long> |
getAllExpiredTokens(boolean clear)
get all of the tokens that are expired for this app |
Map<String,List<PushService.TokenAndType>> |
getAllTokensForUsers(List<String> users)
get all of the tokens for each of the given users |
Map<String,Long> |
getExpiredTokens(boolean clear)
Deprecated. use getAllExpiredTokens(boolean) instead. This method only gets/removes iOS expired tokens, |
Set<PushService.TokenType> |
getSendableDevicesForPayload(Map<String,String> pairs)
get the devices that can be sent to with the given payload. |
Map<String,String> |
getTokensForUsers(List<String> users)
Deprecated. use getAllTokensForUsers(java.util.List) instead. This method only gets iOS tokens. |
void |
registerToken(String username,
String token)
Deprecated. use registerTokenForUser(String, TokenAndType) instead. This method only registers iOS tokens |
void |
registerTokenForUser(String username,
PushService.TokenAndType token)
register a token for a given user |
void |
removeToken(PushService.TokenAndType token)
remove a token from the list of registered tokens |
void |
removeToken(String token)
Deprecated. use removeToken(TokenAndType) instead. This method can only remove iOS tokens. |
void |
sendPush(List<String> tokens,
int badge,
String sound,
String alert)
Deprecated. use sendPushToTokens(java.util.List, java.util.Map) instead. This method only pushes to iOS devices |
void |
sendPush(List<String> recipients,
int badge,
String sound,
String alert,
boolean recipientsAreTokens)
Deprecated. use sendPushToUsers(java.util.List, java.util.Map) instead. This only sends to iOS devices |
void |
sendPushToTokens(List<PushService.TokenAndType> tokens,
Map<String,String> pairs)
Send a push notification to each device identified by the tokens provided. |
void |
sendPushToUsers(List<String> users,
Map<String,String> pairs)
send a push notification to all of the devices registered to the given users. |
| Method Detail |
|---|
void sendPushToTokens(List<PushService.TokenAndType> tokens,
Map<String,String> pairs)
throws PushServiceException
| Payload size range (bytes) | Behavior |
|---|---|
| [0, 256] | Sends to both Android and iOS devices |
| (256, 1024] | Sends to Android only, logs the iOS tokens to which the send would fail, and throws |
| (1024,infinity) | Sends to no devices, logs the failed tokens, and throws |
getSendableDevicesForPayload(java.util.Map) in your code
to check which devices can be sent to given a payload.
| Device | Behavior |
|---|---|
| iOS |
Any value whose key is "badge", "sound" or "alert" will be automatically put into the reserved "aps" dictionary.
Per the iOS push notification documentation:
|
| Android | any value whose key is "collapse_key" will be used as the collapse key for the push notification. if no collapse key is given, "smob" will be used as the collapse key. if a collapse key is given, it will be removed from the payload prior to sending. |
tokens - the tokens to send topairs - the key/value pairs to send
PushServiceException - if an error occurredgetSendableDevicesForPayload(java.util.Map)
void sendPushToUsers(List<String> users,
Map<String,String> pairs)
throws PushServiceException
users - the users to which to sendpairs - the payload to send. This function treats this parameter exactly as does
sendPushToTokens(java.util.List, java.util.Map)
PushServiceException - if an error occurredsendPushToTokens(java.util.List, java.util.Map)
void broadcastPush(Map<String,String> pairs)
throws PushServiceException
pairs - the payload to send. This function treats this parameter exactly as does
sendPushToTokens(java.util.List, java.util.Map), for both size restrictions and content
PushServiceException - if an error occurredsendPushToTokens(java.util.List, java.util.Map)
Map<String,List<PushService.TokenAndType>> getAllTokensForUsers(List<String> users)
throws DatastoreException
users - the users for which to get tokens
DatastoreException - if an error occurred
void removeToken(PushService.TokenAndType token)
throws DatastoreException
token - the token to remove
DatastoreException - if an error occurred
Set<PushService.TokenType> getSendableDevicesForPayload(Map<String,String> pairs)
throws PushServiceException
sendPushToTokens(java.util.List, java.util.Map) or
sendPushToUsers(java.util.List, java.util.Map)
pairs - the proposed payload to test
TokenTypes representing the devices that could be sent to
PushServiceException - if an error occurred
void registerTokenForUser(String username,
PushService.TokenAndType token)
throws DatastoreException
username - the user to which to register the tokentoken - the token to register
DatastoreException - if an error occurred
Map<PushService.TokenAndType,Long> getAllExpiredTokens(boolean clear)
throws DatastoreException
clear - if true, remove all of the returned tokens after this method returns
DatastoreException - if an error occurred
@Deprecated
void sendPush(List<String> tokens,
int badge,
String sound,
String alert)
throws PushServiceException
sendPushToTokens(java.util.List, java.util.Map) instead. This method only pushes to iOS devices
sendPush(tokens, badge, sound, alert, true)
tokens - the device tokens to which the push notification should be sentbadge - the badge for the push notification; specifies the number to be displayed with the app iconsound - the sound to be played by the devicesalert - the text of the alert to be displayed by the devices
PushServiceException - if an error occurs
@Deprecated
void sendPush(List<String> recipients,
int badge,
String sound,
String alert,
boolean recipientsAreTokens)
throws PushServiceException
sendPushToUsers(java.util.List, java.util.Map) instead. This only sends to iOS devices
recipientsAreTokens parameter. If true, the recipients list
is considered to consist of device tokens. If false, the recipients list will be considered to be user IDs. In
either case, tokens need to be registered via the registerToken(String, String) call, before they can be
used.
recipients - the device tokens to which the push notification should be sentbadge - the badge for the push notification; specifies the number to be displayed with the app iconsound - the sound to be played by the devicesalert - the text of the alert to be displayed by the devicesrecipientsAreTokens - the type of entries in the recipients list. true if specifying tokens, false for users
PushServiceException - if an error occurs
@Deprecated
void broadcastPush(int badge,
String sound,
String alert)
throws PushServiceException
broadcastPush(java.util.Map) instead. this method only broadcasts to iOS devices
badge - the badge for the push notification; specifies the number to be displayed with the app iconsound - the sound to be played by the devicesalert - the text of the alert to be displayed by the devices
PushServiceException - if an error occurs
@Deprecated
Map<String,Long> getExpiredTokens(boolean clear)
throws DatastoreException
getAllExpiredTokens(boolean) instead. This method only gets/removes iOS expired tokens,
clear - if true, the set of expired tokens will be cleared after the call. if false, the current token set
will be retained on the server
Map, where the token is the key,
and the value is the expiration time, represented as milliseconds since January 1, 1970 UTC
DatastoreException - if an error occurs
@Deprecated
void registerToken(String username,
String token)
throws DatastoreException
registerTokenForUser(String, TokenAndType) instead. This method only registers iOS tokens
username - a username to associate with the specified tokentoken - iOS device token
DatastoreException - if an error occurs
@Deprecated
Map<String,String> getTokensForUsers(List<String> users)
throws DatastoreException
getAllTokensForUsers(java.util.List) instead. This method only gets iOS tokens.
getExpiredTokens(boolean) to get the expired tokens.
users - list of user IDs
DatastoreException - if an error occurs
@Deprecated
void removeToken(String token)
throws DatastoreException
removeToken(TokenAndType) instead. This method can only remove iOS tokens.
token - token to be removed
DatastoreException - if an error occurs
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||