-
Notifications
You must be signed in to change notification settings - Fork 28
PushoverMessageBuilder
A pushover message is used to add parameters quickly to a message API request. The Builder interface allows a developer to setup a message quickly by chaining set calls. This builder is used on both outbound messages and user validation calls. Below is an example of High priorty outbound message call (message will be highlighted in red in the application)
PushoverMessage msg = PushoverMessage.builderWithApiToken("MY_APP_API_TOKEN")
.setUserId("[USER_ID_TOKEN]")
.setMessage("Welcome to pushover4j!")
.setPriority(MessagePriority.HIGH)
.setTitle("Hellow there...")
.setUrl("https://github.com/sps/pushover4j")
.setTitleForURL("pushover4j github repo")
.setSound("magic")
.build());
Builders can be created in 2 ways: the standard constructor and setCall chain, or jump started with the builderWithApiToken([app_token]) call
- Builder contains a standard
new Builder()
call that can setup a blank builder - PushoverMessage has a static call
builderWithApiToken
that can be used as a shortcut tonew Builder().setApiToken([token])
and is slightly more descriptive of what the builder is for. This call was used in the example above.
Once the builder has been started the builder is finished with the standard build()
call that will return the finished read-only PushoverMessage object.
####The builder supports the following setters:
#####Required: setApiToken(String apiToken); your application's API token. NOTE If using the PushoverMessage.builderWithApiToken this call has already been made.
setUserId(String userId);
the user/group key (not e-mail address) of your user or group.
setMessage(String message);
(required on push notifications, optional others) - your message body to be set
#####Priority: Message priority is an optional field with the system and pushover4j defaulting to 'Normal' priority. However if setting priority to 'Emergency' two other fields become required.
setPriority(MessagePriority priority);
(recommended) - see MessagePriority^ options for different levels supported
^ MessagePriority supported levels.
When Priority == Emergency the following must be set
setRetry(int seconds);
how often the server should retry alerting the user until acknowledged. No less than 30 seconds.
setExpire(int seconds);
how long the server should keep retrying the user unless they acknowledge. System limits to 86400 (24 hours)
#####Fully optional:
setDevice(String device);
your user's device identifier to send the message directly to that device,
setTitle(String title);
your message's title, otherwise servers uses your app's name
setUrl(String url);
a supplementary URL to show with your message
setTitleForURL(String titleForURL);
a title for your supplementary URL
setTimestamp(Long timestamp);
set to a Unix timestamp to have your message show with a particular time. Will be formated to human readable on the application.
setSound(String sound);
set to the name of one of the sounds supported by device clients to override
setCallbackUrl(String url);
a publicly accessable URL that the system will post to