Apple push notification with APNS sharp

I am using the APNS Sharp library for push apple notifications. I disconnected from Here .i use the sample test program provided by the sharp APNS library without any changes. It just doesn't send notifications until I put a breakpoint on this line of code. if I set a breakpoint. I just work great. Is this the expected behavior, or am I doing something wrong. nor do I get any exceptions. Thanks for any help. here is the code

static void Main(string[] args) { bool sandbox = true; string testDeviceToken = "Token"; string p12File = "apn_developer_identity.p12"; string p12FilePassword = "yourpassword"; int sleepBetweenNotifications = 15000; string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File); NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1); service.SendRetries = 5; service.ReconnectDelay = 5000; //5 seconds service.Error += new NotificationService.OnError(service_Error); service.NotificationTooLong += new NotificationService.OnNotificationTooLong(service_NotificationTooLong); service.BadDeviceToken += new NotificationService.OnBadDeviceToken(service_BadDeviceToken); service.NotificationFailed += new NotificationService.OnNotificationFailed(service_NotificationFailed); service.NotificationSuccess += new NotificationService.OnNotificationSuccess(service_NotificationSuccess); service.Connecting += new NotificationService.OnConnecting(service_Connecting); service.Connected += new NotificationService.OnConnected(service_Connected); service.Disconnected += new NotificationService.OnDisconnected(service_Disconnected); Notification alertNotification = new Notification(testDeviceToken); alertNotification.Payload.Alert.Body = "Testing {0}..."; alertNotification.Payload.Sound = "default"; alertNotification.Payload.Badge = i; if (service.QueueNotification(alertNotification)) Console.WriteLine("Notification Queued!"); else Console.WriteLine("Notification Failed to be Queued!"); Console.WriteLine("Cleaning Up..."); service.Close();// if i dont put a break point in here, it simply does not send any notification service.Dispose(); } 

I hope my question is clear ...
Update: I am stuck here. Please anyone can help me.

+3
source share
2 answers

I figured out the problem. it was a bug in the APNS SHARP library stream.

EDIT:
I call this method after the order of the entire notification.
as
service.start ();
and here is the method

  public void Send() { foreach (NotificationConnection conn in this.notificationConnections) { // Console.Write("Start Sending"); conn.start(P12File, P12FilePassword); } } 
+2
source

I see it too. Looking at the NotificationConnection.Close () method, I found this:

// Sleep here to prevent a race condition // in which a notification can be queued during a workflow // sleeping after its cycle, but if we set the closure to true within 100 ms, // notifications in the queue during this time will not be deleted in turn // exit due to closing = true; // 250 ms should be enough time for the loop to delete any remaining notifications // after we stopped receiving above Thread.Sleep (250);

And in the above loop, I found: Thread.Sleep (500);

Setting the timeout in the close method to 1000 fixed it for me;) - answer to: http://code.google.com/p/apns-sharp/issues/detail? id = 41

+1
source

All Articles