views:

69

answers:

1

i use APNS Sharp library for my apple push notification. i have downloded from Here.i use sample test program provided by APNS sharp library without any modification.
it simply does not send any notification until i put break point at that line of code. if i put break point. i just work fine.is this expected behaviour or i am doing something wrong. and also i am not getting any exception. 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 any one can help me.

A: 

i found out the problem. it was error in APNS SHARP library thread workflow.

Nnp
what do you mean? what error? im using some library code in vb.net to do this push to apns. and im getting "notification queued" but the notification never beeing delivered to the device...how is it possible?
Itay Levin
when you say NotificationService service = new NotificationService(), its starts another thred which reads from queue. but before you add any notification to queue that thred already terminated as there was no notification. make sense> if you put break point then listenr thread wont finish because it waiting on break point.
Nnp