ITeye博客

Java APNS开源库apns4j-1.0.1发布

冲杯茶喝 · 2015-04-23 16:59 · 心得体会 · 移动开发 · Markdown

Java APNS开源库apns4j-1.0.1发布

 

开源地址:https://github.com/teaey/apns4j

 

maven依赖:

 

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片

 

  1. <dependency>
  2. <groupId>com.github.teaey</groupId>
  3. <artifactId>apns4j</artifactId>
  4. <version>1.0.1</version>
  5. </dependency>

 

使用方法:使用方法

 

 

[java] view plaincopyprint?在CODE上查看代码片派生到我的代码片

 

  1. KeyStoreWraper keyStore = KeyStoreHelper.getKeyStoreWraper("XXXXXXXX.p12", keyStorePasswd);
  2. AppleNotificationServer appleNotificationServer = new AppleNotificationServer(AppleGateway.ENV_DEVELOPMENT, keyStore);
  3. SecurityConnectionFactory connectionFactory = new SecurityConnectionFactory(appleNotificationServer);
  4. SecurityConnection connection = connectionFactory.getSecurityConnection();
  5. NotifyPayload notifyPayload = new NotifyPayload();
  6. //notifyPayload.setAlert("TEST1");
  7. notifyPayload.setBadge(2);
  8. notifyPayload.setSound("default");
  9. notifyPayload.setAlertBody("Pushed By apns4j");
  10. notifyPayload.setAlertActionLocKey("Button Text");
  11. connection.writeAndFlush(deviceTokenString, notifyPayload);
  12. connection.close();

 

 

有疑问请留言,或者联系本人:

masfay@163.com

微信:teaey_

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。