LiGCMPushMessage Reference
Package: com.applicasa.ApplicasaManager
Declared In: com.applicasa.ApplicasaManager.LiGCMPushMessage
Overview
Applicasa's LiGCMPushMessage class aims to ease and enhance creating, configuring, and sending push notifications in an application. This class provides convenience methods only—it does not alter the way in which an application needs to be registered, or how an application should handle watching for received messages.
Developers are expected to fully understand Google's Google Cloud Messaging for Android documentation.
Tasks
Configuring Push Notifications
setBadge(int)
setSound(String)
setTag(LiJSONObject)
addTag(String, String)
setMessage(String)
Adding Recipients
addRecipient(User)
addRecipients(List
addRecipient(String)
Sending Push Notifications
Instance Methods
addRecipient(User)
Adds a single recipient to a push notification via an Applicasa User object.
public void addRecipient(User user)
Parameters:
user
A User object to use as message recipient.
addRecipients(List)
Adds many recipients to a push notification via a List of Applicasa User objects.
public void addRecipients(List<User> users)
Parameters:
users
A List of User objects to use as message recipients.
addRecipient(String)
Adds a single recipient to a push notification via an Applicasa User.userId value.
public void addRecipient(String userId)
Parameters:
userId
A String indicating the Applicasa User object's UserId value.
setBadge(int)
Accepts an int to indicate what badge value should be added to the app icon.
public void setBadge(int badge)
Parameters:
badge
An int value that indicates what badge number should be added to the app icon.
setSound(String)
Accepts a String indicating the filename of a sound that should be played as an alert.
public void setSound(String sound)
Parameters:
sound
The sound file that should be played as an alert, provided as a String filename.
Discussion:
Sound files should be stored under res/raw/filename.
setTag(LiJSONObject)
Sets additional data in JSON format to the push notification payload.
public void setTag(LiJSONObject tag)
Parameters:
tag
An LiJSONObject providing custom data to add to the push payload. LiJSONObject is a clone of json.org's JSONObject class.
addTag(String, String)
Adds additional data in key-value pairs to the push notification payload.
public void addTag(String key, String value)
Parameters:
key
A String key to represent the data item added.
value
A String value providing the data for the given key.
Discussion:
An alternative to setTag(LiJSONObject), addTag() allows developers to provide key-value pairs that will be added to a JSON object, providing additional data to the push payload.
setMessage(String)
Sets the push notification message that will be displayed to the user.
public void setMessage(String message)
Parameters:
message
A String message that will be sent to users via push notification.
sendPush(LiCallbackPush)
Sends the configured push message and provides a callback method for handling response.
public void sendPush(LiCallbackPush liCallbackPush)
Parameters:
liCallbackPush
A callback handler for handling send completion. The provided callback interface should implement an onComplete() and onFailure(LiErrorHandler) method.