2015-10-20 20 views
-1

我可以发送没有任何错误的通知,但我没有得到任何东西在我的设备上。我尝试了很多解决方案,但我不知道我还能做什么。javapns发送通知,但我收到任何东西

PHP中的certificat和令牌作品... 配置:Java的1.8,Tomcat的7,Javapns 2.2

感谢

代码

BasicConfigurator.configure(); 
URL res = getClass().getClassLoader().getResource("KeyNotification/certificat.p12"); 

File f = new File(res.getFile()); 
List<PushedNotification> notifications = Push.combined("message", 10, "", f.getAbsolutePath(), "password", false, token); 

for (PushedNotification notification : notifications) { 
    if (notification.isSuccessful()) { 
     System.out.println("Push notification sent successfully to: " + notification.getDevice().getToken()); 
    } else { 
     String invalidToken = notification.getDevice().getToken(); 
     Exception theProblem = notification.getException(); 
     theProblem.printStackTrace(); 

     /* If the problem was an error-response packet returned by Apple, get it */ 
     ResponsePacket theErrorResponse = notification.getResponse(); 

     if (theErrorResponse != null) { 
      System.out.println(theErrorResponse.getMessage()); 
     } 
    } 
} 

登录

0 [http-bio-8080-exec-21] DEBUG javapns.communication.ConnectionToAppleServer - Creating SSLSocketFactory 
3 [http-bio-8080-exec-21] DEBUG javapns.communication.ConnectionToAppleServer - Creating SSLSocket to feedback.sandbox.push.apple.com:2196 
1189 [http-bio-8080-exec-21] DEBUG javapns.feedback.FeedbackServiceManager - Found: [0] 
1194 [http-bio-8080-exec-21] DEBUG javapns.notification.Payload - Adding alert [message] 
1194 [http-bio-8080-exec-21] DEBUG javapns.notification.Payload - Adding badge [10] 
1194 [http-bio-8080-exec-21] DEBUG javapns.notification.Payload - Adding sound [] 
1199 [http-bio-8080-exec-21] DEBUG javapns.communication.ConnectionToAppleServer - Creating SSLSocketFactory 
1201 [http-bio-8080-exec-21] DEBUG javapns.communication.ConnectionToAppleServer - Creating SSLSocket to gateway.sandbox.push.apple.com:2195 
1444 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - Initialized Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 1e816c94[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.sandbox.push.apple.com/17.110.227.35,port=2195,localport=63887]] 
1447 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - Building Raw message from deviceToken and payload 
1447 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - Built raw message ID 1 of total length 98 
1447 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - Attempting to send notification: {"aps":{"badge":10,"alert":"message","sound":""}} 
1447 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - to device: 1d8e0488958b92297923884508bf3714835f3581101ede9d3155ded0d8241c3e 
2315 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - Flushing 
2315 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - At this point, the entire 98-bytes message has been streamed out successfully through the SSL connection 
2315 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - Notification sent on first attempt 
2315 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - Reading responses 
7321 [http-bio-8080-exec-21] DEBUG javapns.notification.PushNotificationManager - Closing connection 
Push notification sent successfully to: 1d8e0488958b92297923884508bf3714835f3581101ede9d3155ded0d8241c3e 

回答

0

我解决了我的问题,证书不兼容!

命令行创建证书(aps_development.pem从苹果公司下载,myprivatekey.p12从我的应用程序的私有密钥中的“钥匙串访问”出口):

openssl x509 -in aps_development.cer -inform DER -out aps_development.pem -outform PEM 
openssl pkcs12 -nocerts -in myprivatekey.p12 -out myprivatekey.pem 
openssl pkcs12 -export -inkey myprivatekey.pem -in aps_development.pem -out cert_dev.p12 
相关问题