Push sharp -已达到发送尝试的最大次数

本文关键字:sharp Push | 更新日期: 2023-09-27 17:54:06

我得到这个异常:

已达到发送通知的最大尝试数!

(仅适用于apple通知)每天多次,并在一段时间内阻止通知,然后继续工作。我不知道发生了什么。ServiceException事件正在捕捉这个异常。

我使用pushsharp的默认配置。

下面是我的代码:
     string result = null;
     try
     {
        push = new PushBroker();
        //Wire up the events
        push.OnNotificationSent += NotificationSent;
        push.OnChannelException += ChannelException;
        push.OnServiceException += ServiceException;
        push.OnNotificationFailed += NotificationFailed;
        push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
        push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
        push.OnChannelCreated += ChannelCreated;
        push.OnChannelDestroyed += ChannelDestroyed;
        var appleCert = File.ReadAllBytes(apnCert);
        push.RegisterAppleService(new ApplePushChannelSettings(
            apnProduction, appleCert, apnCertPassword));
        LogNotificationForDevice("", "Apple PN registered Successfully", "");
        push.RegisterGcmService(new GcmPushChannelSettings(androidCertToken));
        LogNotificationForDevice("", "Android PN registered Successfully", "");
        var res = new
        {
            status = "Success"
        };
        result = JsonConvert.SerializeObject(res, Formatting.Indented);
    }
    catch (Exception ex)
    {
        var resex = new
        {
            status = "Failure",
            Message = ex.Message
        };
        result = JsonConvert.SerializeObject(resex, Formatting.Indented);
        LogNotificationForDevice("", "Error when trying to initiate the PushBroker", result);
    }

感谢你的帮助。

Push sharp -已达到发送尝试的最大次数

我使用了这个版本"PushSharp 2.1.2-beta",我再也没有得到这个异常了。