Я пытаюсь использовать библиотеку apns-csharp для отправки push-уведомлений из .NET, я создал сертификат на портале Apple Provision, загружаю его и конвертирую в формат p12, когда пытаюсь загрузить его с кодом:
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");
}
Я получаю внутреннюю ошибку при попытке загрузить сертификат. Если я использую оригинальный сертификат в формате .cer, я не получаю никаких исключений, но на самом деле ничего не отправляется на серверы APNS. Кто-нибудь сталкивался с этой проблемой?