参照文档
https://github.com/jchambers/pushy
按照上面的步骤一步步来.
首先添加pom依赖,刷新maven下载对应的包体;
向公司的管理这索取当前用来测试的.p12文件和对应的密码,和申请时的topic,填到代码中就可以了.
特别注意topic和密码和p12文件都对.
然后去对应的用户中找合适token用户测试正对这个用户的push,看到苹果反馈accepted就可以了.
详细代码如下:
public static void main(String[] argv) throws Exception {
final ApnsClient apnsClient = new ApnsClientBuilder()
.setApnsServer(ApnsClientBuilder.PRODUCTION_APNS_HOST)
.setClientCredentials(new File("D:/codes/Codes/DoomsdayServer1.0/conf/XXXXX.p12"), "xxxxx")
.build();
final SimpleApnsPushNotification pushNotification;
{
final ApnsPayloadBuilder payloadBuilder = new SimpleApnsPayloadBuilder();
payloadBuilder.setAlertBody("Example!~~~");
payloadBuilder.setAlertTitle("e