views:

9

answers:

0

Hi everyone, I trying to use apns-csharp library to send push notification from .NET, I created certificate on Apple Provision Portal, download it and convert to p12 format, when i try to load it with code:

private ActionResult SendAlertPushNotification(string appId, string notificationContent, bool useSandBox)
        {
            NotificationService notificationService = new NotificationService(useSandBox,ApplicationsRepository.GetAPNSCertificateForApplication(appId,useSandBox),"123",1);
            notificationService.ReconnectDelay = 2000;
            notificationService.Error += new NotificationService.OnError(service_Error);
            notificationService.NotificationTooLong += new NotificationService.OnNotificationTooLong(service_NotificationTooLong);

            notificationService.BadDeviceToken += new NotificationService.OnBadDeviceToken(service_BadDeviceToken);
            notificationService.NotificationFailed += new NotificationService.OnNotificationFailed(service_NotificationFailed);
            notificationService.NotificationSuccess += new NotificationService.OnNotificationSuccess(service_NotificationSuccess);
            notificationService.Connecting += new NotificationService.OnConnecting(service_Connecting);
            notificationService.Connected += new NotificationService.OnConnected(service_Connected);
            notificationService.Disconnected += new NotificationService.OnDisconnected(service_Disconnected);
            var devices = ApplicationsRepository.GetPushClientDevicesID(appId);
            foreach (var token in devices)
            {
                var notification = new Notification(token);
                notification.Payload.Alert.Body = notificationContent;
                notification.Payload.Sound = "default";
                notification.Payload.Badge = 1;
                //Queue the notification to be sent
                if (notificationService.QueueNotification(notification))
                    Debug.WriteLine("Notification Queued!");
                else
                    Debug.WriteLine("Notification Failed to be Queued!");
            }
            notificationService.Close();
            ViewData["app"] = ApplicationsRepository.GetApplicationByAppId(appId);
            ViewData["count"] = devices.Count;
            return View("SendSuccess");
        }

I receive internal error when try to load a certificate. If i use original certificate if .cer format, i dont receive any exceptions but nothing is actually sended to APNS servers. Has anyone encountered this problem?