A fork of the pushover4j java client for pushover notification service. Example:
PushoverClient client = new PushoverRestClient();
client.pushMessage(PushoverMessage.builderWithApiToken("MY_APP_API_TOKEN")
.setUserId("USER_ID_TOKEN")
.setMessage("testing!")
.build());
Just that fast. Now the message can be customized with much more control as seen below. We also capture the result from the API call and can reference that for success or error message logging:
// push a message with optional fields
//(note we are reusing the client from the first example here)
Status result = client.pushMessage(PushoverMessage.builderWithApiToken("MY_APP_API_TOKEN")
.setUserId("USER_ID_TOKEN")
.setMessage("Welcome to pushover4j!")
.setDevice("<your device name>")
.setPriority(MessagePriority.HIGH) // LOWEST,QUIET,NORMAL,HIGH,EMERGENCY
.setTitle("Testing")
.setUrl("https://github.com/ilpersi/pushover4j")
.setTitleForURL("pushover4j github repo")
.setSound("magic")
.setImage(new File("cool_image.png"))
.build());
System.out.println(String.format("status: %d, request id: %s", result.getStatus(), result.getRequestId()));
And you can keep up to date with the latest in available sounds with a quick call as well.
// get and print out the list of available sounds:
for (PushOverSound sound : client.getSounds() ) {
System.out.println(String.format("name: %s, id: %s", sound.getName(), sound.getId()));
}
Installation is best done through the Maven build system. We should keep the maven system up to date with releases but you are free to manually install things. Java 6 or higher required.
Use my fork of the pushover-client
or add the following to your POM
<dependency>
<groupId>com.github.ilpersi</groupId>
<artifactId>pushover-client</artifactId>
<version>1.1.1</version>
</dependency>
for the non-maven types, here are the required dependencies
For java 6 users you will need to enhance your security provider. Pushover uses a Diffie-Hillman 1024 for handshake on its new key which Java 6 does not support natively. If your country allows it you may install the Boucny Castle provider to continue using the service. Otherwise newer versions of Java 7 and Java 8 will work natively.
I've integrated all the fixes from hhocker fork and added the latest features available in Pushover
- the possibility to send image attachmets together with messages
- the possibility to use monospace font in notification messages
- the possibility to send HTML formatted notifications