'Pusher Push Notifications SDK for Android'

Pusher Push Notifications SDK for Android clients

License

License

MIT
Categories

Categories

Java Languages
GroupId

GroupId

com.pusher
ArtifactId

ArtifactId

push-notifications-server-java
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

'Pusher Push Notifications SDK for Android'
Pusher Push Notifications SDK for Android clients
Project URL

Project URL

https://github.com/pusher/push-notifications-java
Source Code Management

Source Code Management

https://github.com/pusher/push-notifications-java

Download push-notifications-server-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.pusher/push-notifications-server-java/ -->
<dependency>
    <groupId>com.pusher</groupId>
    <artifactId>push-notifications-server-java</artifactId>
    <version>1.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.pusher/push-notifications-server-java/
implementation 'com.pusher:push-notifications-server-java:1.1.1'
// https://jarcasting.com/artifacts/com.pusher/push-notifications-server-java/
implementation ("com.pusher:push-notifications-server-java:1.1.1")
'com.pusher:push-notifications-server-java:jar:1.1.1'
<dependency org="com.pusher" name="push-notifications-server-java" rev="1.1.1">
  <artifact name="push-notifications-server-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.pusher', module='push-notifications-server-java', version='1.1.1')
)
libraryDependencies += "com.pusher" % "push-notifications-server-java" % "1.1.1"
[com.pusher/push-notifications-server-java "1.1.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.2.10
org.apache.httpcomponents : httpclient jar 4.5.4
com.google.code.gson : gson jar 2.8.0

runtime (1)

Group / Artifact Type Version
com.auth0 : java-jwt jar 3.7.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Pusher Beams Java Server SDK

Build Status

Installation

The compiled library is available in two ways:

Maven

The push-notifications-server-java is available in Maven Central.

<dependencies>
    <dependency>
      <groupId>com.pusher</groupId>
      <artifactId>push-notifications-server-java</artifactId>
      <version>1.1.1</version>
    </dependency>
</dependencies>

Gradle

dependencies {
  compile 'com.pusher:push-notifications-server-java:1.1.1'
}

Download

You can download a version of the .jar directly from Maven.

Usage

Configuring the SDK for Your Instance

Use your instance id and secret (you can get these from the dashboard) to create a Beams PushNotifications instance:

Java

String instanceId = "8f9a6e22-2483-49aa-8552-125f1a4c5781";
String secretKey = "C54D42FB7CD2D408DDB22D7A0166F1D";

PushNotifications pushNotifications = new PushNotifications(instanceId, secretKey);

Kotlin

val instanceId = "8f9a6e22-2483-49aa-8552-125f1a4c5781"
val secretKey = "C54D42FB7CD2D408DDB22D7A0166F1D"

val pn = PushNotifications(instanceId, secretKey)

Publishing a Notification

Once you have created your PushNotifications instance you can publish a push notification to your registered & subscribed devices:

Java

List<String> interests = Arrays.asList("donuts", "pizza");

Map<String, Map> publishRequest = new HashMap();

Map<String, String> alert = new HashMap();
alert.put("alert", "hi");
Map<String, Map> aps = new HashMap();
aps.put("aps", alert);
publishRequest.put("apns", aps);

Map<String, String> fcmNotification = new HashMap();
fcmNotification.put("title", "hello");
fcmNotification.put("body", "Hello world");
Map<String, Map> fcm = new HashMap();
fcm.put("notification", fcmNotification);
publishRequest.put("fcm", fcm);

pushNotifications.publishToInterests(interests, publishRequest);

Kotlin

val interests = listOf("donuts", "pizza")
val publishRequest = hashMapOf(
  "apns" to hashMapOf("aps" to hashMapOf("alert" to "hi")),
  "fcm" to hashMapOf("notification" to hashMapOf("title" to "hello", "body" to "Hello world"))
)

pn.publishToInterests(interests, publishRequest)

com.pusher

Pusher

Pusher makes communication and collaboration APIs that power apps all over the world supported by easy to integrate SDKs for web, mobile, and backend.

Versions

Version
1.1.1
1.1.0
0.9.0