Apple APNs java 客戶端:zpush
Apple APNs java client, based on netty4.
基于netty4實現的蘋果通知推送服務Java客戶端。
特點:
-
支持第三版通知推送,即command = 2。目前的絕大部分Java客戶端都只支持command = 1,即第二版。
-
支持SSL握手成功才返回,可以調用 pushManager.start().sync(); 等待握手成功才開始發送;
-
最大限度重試發送,內部自動處理重連,錯誤重發機制;
-
支持配置RejectListener,即通知被Apple服務器拒絕之后的回調接口;
-
支持配置ShutdownListener,即當shutdown時,沒有發送完的消息處理的回調接口;
-
支持發送統計信息;
-
實現組件分離,可以利用PushClient,FeedbackClient來寫一些靈活的代碼。
-
Notification發送者可以自己定義設置發送的Queue,自己靈活處理阻塞,超時等問題。
Example:
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 BlockingQueuequeue = new LinkedBlockingQueue(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); } }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!