HarunBahcel / apns-sharp

Automatically exported from code.google.com/p/apns-sharp
0 stars 0 forks source link

Push Notification send only when i debug the code..issue #57

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
i am having trouble using this library.i use 
JdSoft??.Apple.Apns.Notifications.Test for my testing. it just work fine in 
debug mode means i have to put break point in vs2008 otehrwise it wont work. 
any idea what could be wrong. if you have any idea then please tell me.. 

my code is as foollows

   public bool SendNotification(string customheader, string customheaderValue, string DeviceTokenID, int BadgeCount)
    {
        try
        {

            bool sandbox = true;

            string testDeviceToken = DeviceTokenID;
            string p12File = "SynsoftGlobalApnsCertificates.p12";

            string p12FilePassword = "server";

            string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File);

            NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1);

            service.SendRetries = 5; //5 retries before generating notificationfailed event
            service.ReconnectDelay = 50000; //50 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);

                //Create a new notification to send
                Notification alertNotification = new Notification(testDeviceToken);

                //alertNotification.Payload.AddCustom("ordId", "NAA_949");
                alertNotification.Payload.AddCustom(customheader, customheaderValue);
                //alertNotification.Payload.Alert.Body = string.Format("NTO NAA_949");
                alertNotification.Payload.Alert.Body = string.Format("Visiting Card");
                alertNotification.Payload.Sound = "default";
                //alertNotification.Payload.Badge = 3;
                alertNotification.Payload.Badge = BadgeCount;

                //Queue the notification to be sent
                if (service.QueueNotification(alertNotification))
                    Console.WriteLine("Notification Queued!");
                else
                    Console.WriteLine("Notification Failed to be Queued!");

                //Sleep in between each message

            Console.WriteLine("Cleaning Up...");

            //First, close the service.  
            //This ensures any queued notifications get sent befor the connections are closed
            service.Close();

            //Clean up
            service.Dispose();

            Console.WriteLine("Done!");
            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }

Original issue reported on code.google.com by ram.shah07 on 23 Feb 2012 at 6:15

GoogleCodeExporter commented 8 years ago
and there is no any exception..occur please help me..

Original comment by ram.shah07 on 23 Feb 2012 at 6:16

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I got the solution for that 
 1st check p12 file is correct  and then  you can check your code upload it on Production. my code is locally not work but when i upload this to server push notification is  working for me.

Original comment by ram.shah07 on 12 Mar 2013 at 5:53