推送通知不会发送到Apple设备

时间:2015-03-18 05:44:34

标签: java ios apache notifications javapns

我正在使用JavaPNS向Apple设备发送推送通知。但它不起作用。我的应用中的代码段:

try {
    BasicConfigurator.configure();
    Push.alert("Hello World!", "D:\\myPushKeyStore.p12", "myPushKeyStorePass", false, "b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607");
}
catch (CommunicationException e) {
    e.printStackTrace();
}
catch (KeystoreException e) {
    e.printStackTrace();
}

以下是错误日志:

1 [http-bio-8080-exec-9] DEBUG javapns.notification.Payload  - Adding alert [Hello World!]
464 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocketFactory
476 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
987 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Initialized Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 599efe20[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.sandbox.push.apple.com/17.172.232.45,port=2195,localport=57282]]
995 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Building Raw message from deviceToken and payload
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Built raw message ID 1 of total length 77
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
996 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
1574 [http-bio-8080-exec-9] INFO javapns.notification.PushNotificationManager  - Attempt failed (Remote host closed connection during handshake)... trying again
1574 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
1842 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
1842 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
2388 [http-bio-8080-exec-9] INFO javapns.notification.PushNotificationManager  - Attempt failed (Remote host closed connection during handshake)... trying again
2388 [http-bio-8080-exec-9] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSocket to gateway.sandbox.push.apple.com:2195
2658 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  - Attempting to send notification: {"aps":{"alert":"Hello World!"}}
2658 [http-bio-8080-exec-9] DEBUG javapns.notification.PushNotificationManager  -   to device: b3ead5d64ba0e08241e236f3ee041d8a9f036b39a0b0537e99a5f8b72ce40607
3217 [http-bio-8080-exec-9] ERROR javapns.notification.PushNotificationManager  - Attempt to send Notification failed and beyond the maximum number of attempts permitted
3220 [http-bio-8080-exec-9] ERROR javapns.notification.PushNotificationManager  - Delivery error
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

我对密钥库文件有任何问题吗?

1 个答案:

答案 0 :(得分:0)

最后我发现问题是由于导致SSL握手错误的p12证书造成的。
我在获取正确的p12文件时参考Cannot send push notifications using Javapns/Javaapns SSL handshake failure解决方案。谢谢!

相关问题