【问题标题】:pushsharp ios notification not workpushsharp ios通知不起作用
【发布时间】:2015-02-18 14:02:40
【问题描述】:

我尝试使用 pushsharp 库发送 iOS 推送通知,但我收到了

已达到最大发送尝试次数

这是我的代码(请注意,我正在实现 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);
        }
    }
}

【问题讨论】:

    标签: c# push-notification pushsharp


    【解决方案1】:

    很可能与苹果推送网关的连接被阻止,请尝试使用telnet:

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

    确保它们没有被阻止

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-30
      • 1970-01-01
      • 1970-01-01
      • 2014-06-09
      • 2017-06-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多