标签:java apns apple push notification
简单说下实现苹果通知推送服务(APNs)客户端的一些要注意的地方:
因此发送者要缓存已经发送的Notification,最好设置Notification identifier为增长的整数序列,当收到Error response里,从缓存里取出比Error response的identifier要大的Notification,再次重新发送;
特点:
public class MainExample {
public static void main(String[] args) throws InterruptedException {
Environment environment = Environment.Product;
String password = "123456";
String keystore = "/home/hengyunabc/test/apptype/app_type_1/productAPNS.p12";
PushManager pushManager = new PushManagerImpl(keystore, password, environment);
//set a push queue
BlockingQueue<Notification> queue = new LinkedBlockingQueue<Notification>(8192);
pushManager.setQueue(queue );
//waiting for SSL handshake success
pushManager.start().sync();
//build a notification
String token = "5f6aa01d8e3358949b7c25d461bb78ad740f4707462c7eafbebcf74fa5ddb387";
Notification notification = new NotificationBuilder()
.setToken(token)
.setBadge(1)
.setPriority(5)
.setAlertBody("xxxxx").build();
//put notification into the queue
queue.put(notification);
TimeUnit.SECONDS.sleep(10);
//get statistic info
Statistic statistic = pushManager.getStatistic();
System.out.println(statistic);
}
}ZPush--基于netty4实现的苹果通知推送服务(APNs)Java客户端,布布扣,bubuko.com
ZPush--基于netty4实现的苹果通知推送服务(APNs)Java客户端
标签:java apns apple push notification
原文地址:http://blog.csdn.net/hengyunabc/article/details/25435739