标签:消息 product rac 问题 seconds 回调接口 command 配置 main
简单说下实现苹果通知推送服务(APNs)client的一些要注意的地方:
因此发送者要缓存已经发送的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)Javaclient
标签:消息 product rac 问题 seconds 回调接口 command 配置 main
原文地址:http://www.cnblogs.com/cynchanpin/p/6914433.html