Apple Push Notification Service 的 Java 實現:apns4j
apns4j 是 Apple Push Notification Service 的 Java 實現!
Maven:
<dependency> <groupId>com.github.teaey</groupId> <artifactId>apns4j</artifactId> <version>1.0.1</version> </dependency>
示例代碼:
KeyStoreWraper keyStore = KeyStoreHelper.getKeyStoreWraper("XXXXXXXX.p12", keyStorePasswd);
AppleNotificationServer appleNotificationServer = new AppleNotificationServer(AppleGateway.ENV_DEVELOPMENT, keyStore);
SecurityConnectionFactory connectionFactory = new SecurityConnectionFactory(appleNotificationServer);
SecurityConnection connection = connectionFactory.getSecurityConnection();
NotifyPayload notifyPayload = new NotifyPayload();
//notifyPayload.setAlert("TEST1");
notifyPayload.setBadge(2);
notifyPayload.setSound("default");
notifyPayload.setAlertBody("Pushed By apns4j");
notifyPayload.setAlertActionLocKey("Button Text");
connection.writeAndFlush(deviceTokenString, notifyPayload);
connection.close(); 本文由用戶 xf3f 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!