javapns-jdk16
javapns-jdk16 copied to clipboard
Invalid keystore format! Make sure it is PKCS12...
Hi, I need to use javaapns loop to push the message,The first message is a success。Later there will be a mistake。What should I do to avoid these?
look my code:
Test main
ApnsTest apnsTest = new ApnsTest(); List<String> devices = new ArrayList<String>(); devices.add("3b9fc52cf1df226e9aeb2ae90b6e94c4ef8144f0de2418ec170d5ee96ea3a3da"); for (int i = 0; i < 3; i++) { apnsTest.send(devices, keystore, password, true); }
ApnsTest
`public void send (List<String> devices, Object keystore, String password, boolean production) { PushNotificationPayload payload = PushNotificationPayload.complex(); try { payload.addAlert("Hello World!"); payload.addSound("defult"); payload.addCustomDictionary("url", "http://www.baidu.com"); payload.addCustomDictionary("type", "Url"); // etc. payload.addCustomDictionary("pushId",111); // etc. payload.addCustomDictionary("forumkey","sadasds"); // etc. List<PushedNotification> notifications = Push.payload(payload, keystore, password, production, devices); for (PushedNotification notification : notifications) { if (notification.isSuccessful()) { System.out.println("Push notification sent successfully to: " + notification.getDevice().getToken()); } else { String invalidToken = notification.getDevice().getToken();
System.out.println("invalidToken :"+invalidToken);
ResponsePacket theErrorResponse = notification.getResponse();
if (theErrorResponse != null) {
System.out.println(theErrorResponse.getMessage());
}
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CommunicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (KeystoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} `
error:
`Push notification sent successfully to: 3b9fc52cf1df226e9aeb2ae90b6e94c4ef8144f0de2418ec170d5ee96ea3a3da
javapns.communication.exceptions.InvalidKeystoreFormatException: Invalid keystore format! Make sure it is PKCS12...
at javapns.communication.KeystoreManager.wrapKeystoreException(KeystoreManager.java:172)
at javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:66)
at javapns.communication.KeystoreManager.ensureReusableKeystore(KeystoreManager.java:87)
at javapns.communication.AppleServerBasicImpl.
at com.goyoo.test.ApnsTest.main(ApnsTest.java:53)`
thank