在 iOS 中接收推送通知时出现问题

Issue in receiving Push Notifications in iOS

我在从 2 个不同的服务器接收推送通知时遇到了一些问题。服务器的后端代码是用 Java 编写的,我已经将 javapns 库用于苹果推送通知。当我收到通知(来自其中一台服务器)时,我得到以下日志语句,

2015-11-06/12:17:15.829 [DEBUG] [] [javapns.notification.Payload] - Adding alert [Alert Message]

2015-11-06/12:17:16.054 [DEBUG] [] [javapns.communication.ConnectionToAppleServer] - Creating SSLSocketFactory

2015-11-06/12:17:16.127 [DEBUG] [] [javapns.communication.ConnectionToAppleServer] - Creating SSLSocket to gateway.sandbox.push.apple.com:2195

2015-11-06/12:17:16.776 [DEBUG] [] [javapns.notification.PushNotificationManager] - Initialized Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 6644621c[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.sandbox.push.apple.com/17.172.232.45,port=2195,localport=57181]]

2015-11-06/12:17:16.778 [DEBUG] [] [javapns.notification.PushNotificationManager] - Building Raw message from deviceToken and payload

2015-11-06/12:17:16.779 [DEBUG] [] [javapns.notification.PushNotificationManager] - Built raw message ID 1 of total length 91

2015-11-06/12:17:16.779 [DEBUG] [] [javapns.notification.PushNotificationManager] - Attempting to send notification: {"aps":{"alert":"Alert Message"}}

2015-11-06/12:17:16.779 [DEBUG] [] [javapns.notification.PushNotificationManager] - to device: e61aa2adfa16449f894b317ea3b4dbbfe4589000abdec7c8c0eb3c7b92654e4c

2015-11-06/12:17:17.696 [DEBUG] [] [javapns.notification.PushNotificationManager] - Flushing

2015-11-06/12:17:17.696 [DEBUG] [] [javapns.notification.PushNotificationManager] - At this point, the entire 91-bytes message has been streamed out successfully through the SSL connection

2015-11-06/12:17:17.696 [DEBUG] [] [javapns.notification.PushNotificationManager] - Notification sent on first attempt

2015-11-06/12:17:17.696 [DEBUG] [] [javapns.notification.PushNotificationManager] - Reading responses

2015-11-06/12:17:22.698 [DEBUG] [] [javapns.notification.PushNotificationManager] - Closing connection

但是,当我没有收到通知(来自其他服务器)时,我得到以下日志,

2015-11-20/13:37:50.539 [DEBUG] [] [javapns.notification.Payload] - Adding alert [Alert Message]

2015-11-20/13:37:50.543 [DEBUG] [] [javapns.notification.PushNotificationManager] - Reading responses

2015-11-20/13:37:50.545 [DEBUG] [] [javapns.notification.PushNotificationManager] - Closing connection

在这里,我没有收到任何关于创建 SSL 套接字工厂或其他突出显示文本的日志语句。 ConnectionToAppleServer class 没有被调用。所以,我怀疑我是否缺少任何 jar 文件。

注意:我在两个服务器中使用相同的开发证书。

任何帮助将不胜感激。

问题不在于开发人员证书或与 iOS 相关的任何 jar 文件。服务器代码被编写为向 android 和 iOS 发送通知。并且缺少一些与 android 相关的 jar 文件。因此,在后端,控制力到达编写发送 iOS 通知的代码的部分。这就是问题所在。一旦添加了这些 jar 文件,一切正常!!