0

I try to send iOS push notifications using pushsharp library but I got

the maximum send attempts was reached

This is my code (note that I'm implementing pushbroker event function but I'm not showing it here):

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);
        }
    }
}
balexandre
  • 73,608
  • 45
  • 233
  • 342

1 Answers1

0

Most likely the connections to apple push gateways are blocked,please try to use telnet:

telnet gateway.push.apple.com 2195
telnet gateway.sandbox.push.apple.com 2195

make sure they are not blocked

Ala' Alnajjar
  • 788
  • 1
  • 11
  • 23