sajidhalai / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by hirant...@gmail.com on 26 Apr 2012 at 8:55

GoogleCodeExporter commented 9 years ago
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

Original comment by hirant...@gmail.com on 26 Apr 2012 at 8:57

GoogleCodeExporter commented 9 years ago
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?

Original comment by sype...@gmail.com on 26 Apr 2012 at 9:53

GoogleCodeExporter commented 9 years ago
So, can you please help me to create the payload?

Original comment by hirant...@gmail.com on 26 Apr 2012 at 10:23

GoogleCodeExporter commented 9 years ago
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.

Original comment by sype...@gmail.com on 27 Apr 2012 at 1:37

GoogleCodeExporter commented 9 years ago
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?

Original comment by hirant...@gmail.com on 27 Apr 2012 at 1:24

GoogleCodeExporter commented 9 years ago
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.

Original comment by hirant...@gmail.com on 27 Apr 2012 at 1:36

GoogleCodeExporter commented 9 years ago
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...)

Original comment by sype...@gmail.com on 27 Apr 2012 at 2:19

GoogleCodeExporter commented 9 years ago
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();  
       }     
    } 

Original comment by hirant...@gmail.com on 27 Apr 2012 at 3:58

GoogleCodeExporter commented 9 years ago
Closing following confirmation that there is no longer an issue.

Original comment by sype...@gmail.com on 30 Apr 2012 at 6:09