8000 webpush-java/ at 3.0.0 · armdev/webpush-java · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History

README.md

WebPush

A Web Push library for Java 7. Supports payloads and VAPID.

Build Status

Installation

For Gradle, add the following dependency to build.gradle:

compile group: 'nl.martijndwars', name: 'web-push', version: '3.0.0'

For Maven, add the following dependency to pom.xml:

<dependency>
    <groupId>nl.martijndwars</groupId>
    <artifactId>web-push</artifactId>
    <version>3.0.0</version>
</dependency>

Usage

First, create an instance of the push service:

pushService = new PushService(...);

Then, create a notification based on the user's subscription:

Notification notification = new Notification(...);

To send a push notification:

pushService.send(notification);

Use sendAsync instead of send to get a Future<HttpResponse>:

pushService.sendAsync(notification);

See doc/UsageExample.md for detailed usage instructions. If you plan on using VAPID, read doc/VAPID.md.

Testing

Our integration tests use Web Push Testing Service (WPTS) to automate browser interaction. To install WPTS:

npm install web-push-testing-service -g

Then, to start WPTS:

web-push-testing-service start wpts

Finally, to run all tests:

./gradlew test

Credit

To give credit where credit is due, the PushService is mostly a Java port of marco-c/web-push. The HttpEce class is mostly a Java port of martinthomson/encrypted-content-encoding.

Documentation

Related

0