/spring-boot-sample-batch-with-apns-gcm

Simple Spring Boot Application with GcmPush bean which is a wrapper bean of Gcm-Server and Javapns

Primary LanguageJava

spring-boot-sample-batch-with-apns-gcm

This is a sample application for APNS and GCM on top of spring-boot-sample-batch

Background

In my company, I had a chance to make an internal "Push Server" which is a gateway server to APNS and GCM.

So I decided to use Javapns and Gcm-Server which are one of the most popular libraries in Java.

I made spring wrapping beans of Javapns and Gcm-Server. I also used spring-boot-sample-batch since it could be the most feasible use case for developers.

Dependency

Sample Code

@Resource
GcmPush gcmPush;

@Test
public void testSendPush() throws Exception {
  String REGISTRATION_ID = "SAMPLE REG ID";
  String content = "This is Gcm Test.";
  String data = "{\"val\":\"\",\"content\":\"" + content  + "}";

  GcmPushInfo info = new GcmPushInfo();
  info.setData(data);
  regIdList.add(REGISTRATION_ID);
  info.setRegIdList(regIdList);
  GcmMulticatResult result = gcmPush.sendPush(info);
}

@Resource
ApnsPush apnsPush;

@Test
public void testPushBadge() throws Exception {
  String SAMPLE_DEVICE_TOKEN = "PLEASE ENTER A SAMPLE DEVICE TOKEN";
  List<String> deviceTokenList = new ArrayList<String>();
  deviceTokenList.add(SAMPLE_DEVICE_TOKEN);
  apnsPush.badge(10, "KEYSTORE PATH", "PASSWORD", false, deviceTokenList);
}