使用Javapns苹果推送通知服务 [英] Apple Push Notification Service using Javapns

查看:635
本文介绍了使用Javapns苹果推送通知服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code发送通知到苹果通知服务器。

I'm using the following code to send notification to the Apple Notification Server.

import javapns.Push;
import javapns.communication.exceptions.CommunicationException;
import javapns.communication.exceptions.KeystoreException;

public class APN 
{
   public static void main(String[] args) {
        try {
            Push.alert("Hello World!", "keystore.p12", "mypassword", false, "myDeviceIdentifier");
        } 
        catch (CommunicationException e) {
           e.printStackTrace();
        } 
        catch (KeystoreException e) {
            e.printStackTrace();
        }
   }
}

我已经包含在文档 Javapns 规定的全部罐子。结果
然而,当我执行此code,它抛出以下异常。

I've included all the jars specified at the documentation of Javapns.
However when I execute this code, it is throwing following exception.

log4j:WARN No appenders could be found for logger (javapns.notification.Payload).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
javapns.communication.exceptions.CommunicationException: Communication exception:
java.net.ConnectException: Operation timed out
at javapns.communication.ConnectionToAppleServer.getSSLSocket(ConnectionToAppleServer.java:158)
at javapns.notification.PushNotificationManager.initializeConnection(PushNotificationManager.java:106)
at javapns.Push.sendPayload(Push.java:171)
at javapns.Push.alert(Push.java:47)
at com.mydomain.myapp.APN.main(APN.java:12)
Caused by: java.net.ConnectException: Operation timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:570)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:371)
at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
at javapns.communication.ConnectionToAppleServer.getSSLSocket(ConnectionToAppleServer.java:155)
... 4 more

我创建中.P12证书,我有64个字长度的设备标识符。

I've created the .p12 certificate and I've got the device identifier of 64 words length.

请,给我建议的解决方案。结果
任何帮助将AP preciated。

Please, suggest me the solution.
Any help will be appreciated.

推荐答案

信息的关键部分是:

java.net.ConnectException:操作超时

java.net.ConnectException: Operation timed out

您一定要运行此code中的服务器可以连接到苹果服务器APN端口上指定?

Are you sure the server running this code can connect to the apple apn server on the port you specified?

提示:使用Telnet来验证

Hint: use telnet to verify.

这篇关于使用Javapns苹果推送通知服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆