push-notificationapple-push-notificationsjavapns

Issue in receiving Push Notifications in iOS


I face some issues in receiving push notification from 2 different servers. The servers' backend code is written in Java and I have used javapns library for apple push notifications. When I receive notification (from one of the servers), I get the following log statements,

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

But, when I do not receive the notification (from the other server), I get the following log,

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

Here, I am not getting any log statements regarding the creation of SSL Socket Factory or other highlighted texts. And the ConnectionToAppleServer class is not getting called. So, I doubt whether I am missing any jar files.

NOTE: I am using same development certificate in both the servers.

Any help will be appreciated.


Solution

  • The problem was not with the developer certificates or any jar files related to iOS. The server code was written to send notifications to both android and iOS. And some jar files related with android were missing. So, in the back end, the control dint reach the part where the code to send iOS notifications was written. That was the problem. Once, those jar files are added, everything works fine!!