mwkirk / javapns

Test import of svn javapns repo from Google Code
3 stars 0 forks source link

Device not receiving notifications although javaapns doesn't log any errors #119

Closed mwkirk closed 11 years ago

mwkirk commented 11 years ago

Original author: hirant...@gmail.com (April 26, 2012 20:55:45)

What steps will reproduce the problem? 1.Create a Proxy and verify the key store - Success 2.Create AppleNotificationServer instance and PushNotificationManager instance - Success 3.Initialize the Manager and Push notifications.

What is the expected output? What do you see instead? Below messages were logged from the tool but message was not delivered to the intended device. All notifications pushed successfully (1): [1] transmitted {"aps":{},"Build Successfull":"0715"} on first attempt to token cdd6a..c1c6f What version of the product are you using? On what operating system? Java apns 2.2 and Windoes XP professional

Please provide any additional information below. Every configurations seems to be fine and my programme is logging as the message is successfully sent, But the targetted device is not receiving the message. Any way the Push.Test() method was successful with my certificate and the token without the proxy settings.

The Method is as follows. public void sendNotification(String releaseId)
throws Exception {
try {

     PushNotificationPayload payLoad = new PushNotificationPayload();

     payLoad.addCustomDictionary("Build Successful", "0715");

     ProxyManager.setProxy("Host", "Port");

     Device device = new BasicDevice(releaseId);

     verifyKeystore(new File("cert.p12"),"certpwd", false);

     AppleNotificationServer server = new AppleNotificationServerBasicImpl(new File("cert.p12"), "certpwd", false);

     System.out.println("Host-" + server.getProxyHost());
     System.out.println("Port-" + server.getProxyPort());

     PushNotificationManager manager = new PushNotificationManager();

     manager.initializeConnection(server);

     PushedNotification notification = manager.sendNotification(device, payLoad);

     FeedbackServiceManager feedbackService = new FeedbackServiceManager();

     AppleFeedbackServer appleServer = new AppleFeedbackServerBasicImpl(new File("cert.p12"), " certpwd ", false);

     List<Device> devices= feedbackService.getDevices(appleServer);

     manager.stopConnection();

     List<PushedNotification> notifications = new ArrayList<PushedNotification>();

     System.out.println("Status-Notification" + notification.isSuccessful());
     System.out.println("Status -Response" + notification.getResponse());

     notifications.add(notification);

     printPushedNotifications(notifications);

   }   
   catch (Exception e) {  
       e.printStackTrace();  
   }     
}       

Original issue: http://code.google.com/p/javapns/issues/detail?id=119

mwkirk commented 11 years ago

From hirant...@gmail.com on April 26, 2012 20:57:13 All these steps were successful: 1.Create a Proxy and verify the key store - Success 2.Create AppleNotificationServer instance and PushNotificationManager instance - Success 3.Initialize the Manager and Push notifications - Success

mwkirk commented 11 years ago

From sype...@gmail.com on April 26, 2012 21:53:12 The way you create your payload results in an empty standard "aps" dictionary... What happens if you add an alert to your payload, while leaving the rest of your code intact?

mwkirk commented 11 years ago

From hirant...@gmail.com on April 26, 2012 22:23:07 So, can you please help me to create the payload?

mwkirk commented 11 years ago

From sype...@gmail.com on April 27, 2012 01:37:16 I do not know what your iOS application's particular needs are, so it's difficult to help beyond what is already in the documentation. There are several examples in the Basic Push Notification and Advanced Push Notification wiki pages on this site which should help you get on the right track. Your code is overly complex and I'm not sure how you ended up with that, but the library is designed to be much, much simpler to use, as you will see in the documentation. Thank you.

mwkirk commented 11 years ago

From hirant...@gmail.com on April 27, 2012 13:24:55 Even this resulted the same:

public void sendNotification(String token)
throws Exception {
try {

       ProxyManager.setProxy("proxy.net", "8443");

       List<PushedNotification> notifications = new ArrayList<PushedNotification>();

       notifications =Push.test(new File("CIGMobiSuite.p12"), "cigmobisuite", false, token);

       printPushedNotifications(notifications);

   }   
   catch (Exception e) {  
       e.printStackTrace();  
   }     
} 

According to the logs the message was successfully pushed. But device didn't receive any messages.

Log Message:

All notifications pushed successfully (1): [1] transmitted {"aps":{"alert":"JAVAPNS DEBUG ALERT 1\n2012/04/27 09:20:49\ngateway.sandbox.push.apple.com\nCDD6\u20261C6F [Id:1] Exp:T+86400\nEnhanced format / UTF-8"}} on first attempt to token cdd6a..c1c6f

Can you kindly let me know a cause for this?

mwkirk commented 11 years ago

From hirant...@gmail.com on April 27, 2012 13:36:28 Please note that I need to send the messages via a proxy as I am behind a firewall and I think this is the correct way to do it. When I commented the ProxyManager.setProxy("proxy.net", "8443") statement my code throws a connection time out exception. So, After I add this statement I didn't get any errors and I think this is the way that this tool is designed to work with a proxy.

mwkirk commented 11 years ago

From sype...@gmail.com on April 27, 2012 14:19:23 Have you tested your code outside of a proxy, just to rule out that the proxy might be the issue?

Are you positively sure that your app is configured to receive notifications, that you are using the right APNS server for your certificate, that your app is built with the same certificate, that your device's date and time are correctly set, etc.? (just covering the basics...)

mwkirk commented 11 years ago

From hirant...@gmail.com on April 27, 2012 15:58:15 This code worked fine for me and now I can successfully send messages without any issues. Thanks a lot for your quick response and for the directions provided.

public void sendNotification(String token)
throws Exception {
try {

       PushNotificationPayload payLoad = new PushNotificationPayload();

       payLoad.addCustomAlertBody("Build Successfull 0715");

       ProxyManager.setProxy("proxy.net", "8443");           

       List<PushedNotification> notifications = new ArrayList<PushedNotification>();

       notifications =Push.payload(payLoad, new File("CIGMobiSuite.p12"), "cigmobisuite", false, token);

       printPushedNotifications(notifications);

   }   
   catch (Exception e) {  
       e.printStackTrace();  
   }     
} 
mwkirk commented 11 years ago

From sype...@gmail.com on April 30, 2012 18:09:15 Closing following confirmation that there is no longer an issue.