---
title: "Java APNS开源库apns4j-1.0.1发布"
author: "冲杯茶喝"
date: "2015-04-23T16:59:56Z"
tags: []
categories: ["移动开发"]
slug: "java-apns-apns4j-1-0-1"
draft: false
lastmod: "2016-05-19T15:35:02Z"
id: 2205530
url: "https://teaey.iteye.com/blog/2205530"
---

Java APNS开源库apns4j-1.0.1发布

 

开源地址：[https://github.com/teaey/apns4j](https://github.com/teaey/apns4j)

 

maven依赖：

 

**\[html]** [view plain](http://blog.csdn.net/teaey/article/details/45223845 "view plain")[copy](http://blog.csdn.net/teaey/article/details/45223845 "copy")[print](http://blog.csdn.net/teaey/article/details/45223845 "print")[?](http://blog.csdn.net/teaey/article/details/45223845 "?")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/651431 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/651431/fork "派生到我的代码片")

 

1. &lt;dependency&gt;
2. &lt;groupId&gt;com.github.teaey&lt;/groupId&gt;
3. &lt;artifactId&gt;apns4j&lt;/artifactId&gt;
4. &lt;version&gt;1.0.1&lt;/version&gt;
5. &lt;/dependency&gt;

 

使用方法：[使用方法](https://github.com/teaey/apns4j/blob/master/src/test/java/cn/teaey/apns4j/TestSample.java)

 

 

**\[java]** [view plain](http://blog.csdn.net/teaey/article/details/45223845 "view plain")[copy](http://blog.csdn.net/teaey/article/details/45223845 "copy")[print](http://blog.csdn.net/teaey/article/details/45223845 "print")[?](http://blog.csdn.net/teaey/article/details/45223845 "?")[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/651431 "在CODE上查看代码片")[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/651431/fork "派生到我的代码片")

 

01. KeyStoreWraper keyStore = KeyStoreHelper.getKeyStoreWraper("XXXXXXXX.p12", keyStorePasswd);
02. AppleNotificationServer appleNotificationServer = new AppleNotificationServer(AppleGateway.ENV\_DEVELOPMENT, keyStore);
03. SecurityConnectionFactory connectionFactory = new SecurityConnectionFactory(appleNotificationServer);
04. SecurityConnection connection = connectionFactory.getSecurityConnection();
05. NotifyPayload notifyPayload = new NotifyPayload();
06. //notifyPayload.setAlert("TEST1");
07. notifyPayload.setBadge(2);
08. notifyPayload.setSound("default");
09. notifyPayload.setAlertBody("Pushed By apns4j");
10. notifyPayload.setAlertActionLocKey("Button Text");
11. connection.writeAndFlush(deviceTokenString, notifyPayload);
12. connection.close();

 

 

有疑问请留言，或者联系本人：

masfay@163.com

微信：teaey_