代码实现
maven引入第三方库
<dependency>
<groupId>com.eatthepath</groupId><artifactId>pushy</artifactId><version>0.15.4</version>
</dependency>
代码示例
InputStream certificateStream;String deviceToken = "";try {URL url = new URL("");HttpURLConnection uc = (HttpURLConnection) url.openConnection();uc.setDoInput(true);uc.connect();certificateStream = uc.getInputStream();final ApnsClient apnsClient = new ApnsClientBuilder().setApnsServer(ApnsClientBuilder.DEVELOPMENT_APNS_HOST).setClientCredentials(certificateStream, "1234").build();final SimpleApnsPushNotification pushNotification = new SimpleApnsPushNotification(deviceToken, "", "{\"aps\":{\"alert\":\"Hello World!!!\"}}" );final PushNotificationFuture<SimpleApnsPushNotification, PushNotificationResponse<SimpleApnsPushNotification>>sendNotificationFuture = apnsClient.sendNotification(pushNotification);sendNotificationFuture.thenAccept(response -> {System.out.println(response);});} catch (Exception e) {e.printStackTrace();}