Я пытаюсь отправить push-уведомления iOS с помощью библиотеки pushsharp, но получаю
достигнуто максимальное количество попыток отправки
Это мой код (обратите внимание, что я реализую функцию события pushbroker, но здесь ее не показываю):
public class PushNotificationApple
{
private static PushBroker _pushBroker;
public PushNotificationApple()
{
if (_pushBroker == null)
{
//Create our push services broker
_pushBroker = new PushBroker();
_pushBroker.OnNotificationSent += NotificationSent;
_pushBroker.OnChannelException += ChannelException;
_pushBroker.OnServiceException += ServiceException;
_pushBroker.OnNotificationFailed += NotificationFailed;
_pushBroker.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
_pushBroker.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
_pushBroker.OnChannelCreated += ChannelCreated;
_pushBroker.OnChannelDestroyed += ChannelDestroyed;
PushBroker broker = new PushBroker();
string certpass = "XXXXXX.";
var appleCert = File.ReadAllBytes("c:\\certifIOS\\Certificates.p12");
_pushBroker.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, certpass)); //Extension method
}
}
public void SendNotification(string deviceToken, string message)
{
//Fluent construction of an iOS notification
//IMPORTANT: For iOS you MUST MUST MUST use your own DeviceToken here that gets generated within your iOS app itself when the Application Delegate
// for registered for remote notifications is called, and the device token is passed back to you
if (_pushBroker != null)
{
AppleNotification appnotif = new AppleNotification() ;
_pushBroker.QueueNotification(appnotif
.ForDeviceToken(deviceToken)//the recipient device id
.WithAlert(message)//the message
.WithBadge(1)
.WithSound("default")
);
bool v = appnotif.IsValidDeviceRegistrationId();
_pushBroker.StopAllServices(true);
}
}
}