Skip to content

Latest commit

 

History

History
52 lines (44 loc) · 1.48 KB

File metadata and controls

52 lines (44 loc) · 1.48 KB

fcm-sender-java

fcm-sender-java is libary for sending notification to FCM server.

Add dependency

<repositories>
  <repository>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
    <id>bintray-enzinier-fcm-sender-java</id>
    <name>bintray</name>
    <url>http://dl.bintray.com/enzinier/fcm-sender-java</url>
  </repository>
</repositories>

<dependency>
  <groupId>com.illicis</groupId>
  <artifactId>fcm-sender-java</artifactId>
  <version>0.0.1</version>
</dependency>
compile 'com.illicis:fcm-sender-java:0.0.1'

Usage

DownstreamHttpNotification downstreamHttpNotificationAndroid =
  DownstreamHttpNotificationAndroid.builder()
    .setTitle("Hello")
    .setBody("This is test notification.")
    .build();

DownstreamHttpMessages downstreamHttpMessages =
  new DownstreamHttpMessages(registrationIdForTest, null)
    .setContentAvailable(true)
    .setNotification(downstreamHttpNotificationAndroid)
    .setData(this.getDownstreamHttpData())
    .setDryRun(false);

FcmSender fcmSender = new FcmSender("Your Server Key");
DownstreamHttpResponse downstreamHttpResponse = fcmSender.sendNotification(downstreamHttpMessages);

You can find server key from setting of firebase console. (Project Setting > Cloud Messaging) DownstreamHttpData is just interface for getting common parameter. Therefore you should write code to include your own data implement DownstreamHttpData.

Reference