【问题标题】:PushSharp APNS notification error The function requested is not supportedPushSharp APNS 通知错误 请求的功能不受支持
【发布时间】:2019-08-01 14:45:56
【问题描述】:

我正在使用 PushSharp 4.0.10 在 Apns 代理的 OnNotificationFailed 事件中,我收到“不支持请求的功能”异常。有我的经纪人创作者

private static ApnsServiceBroker CreateApnsBroker(string certificate)
{
    // Configuration (NOTE: .pfx can also be used here)
    var config = newApnsConfiguration(
        ApnsConfiguration.ApnsServerEnvironment.Sandbox,
        certificate,
        ConfigurationManager.AppSettings["Cert_Passwd"],
        false);

    // Create a new broker
    var apnsBroker = new ApnsServiceBroker(config);

    // Wire up events
    apnsBroker.OnNotificationFailed += (notification, aggregateEx) =>
    {
        aggregateEx.Handle(ex =>
        {
            // See what kind of exception it was to further diagnose
            if (ex is ApnsNotificationException notificationException)
            {
                // Deal with the failed notification
                var apnsNotification = notificationException.Notification;
                var statusCode = notificationException.ErrorStatusCode;

                Logger.Info($"Apple Notification Failed:
                    ID={apnsNotification.Identifier},
                    Code={statusCode}",
                    ex);
            }
            else
            {
                // Inner exception might hold more useful information
                // like an ApnsConnectionException
                Logger.Info($"Apple Notification Failed for some unknown reason:
                    {ex.InnerException}",
                    ex);
            }
                // Mark it as handled
                return true;
            });
    };

    apnsBroker.OnNotificationSucceeded += (notification) =>
    {
        Logger.Info($"Apple Notification Sent for device {notification.DeviceToken}");
    };

    return apnsBroker;
}

发送通知

private static void QueueNotification(
    ApnsServiceBroker apnsBroker,
    string deviceToken,
    string payload)
{
    // Queue a notification to send
    apnsBroker.QueueNotification(new ApnsNotification
    {
        DeviceToken = deviceToken,
        Payload = JObject.Parse(payload),
        Expiration = DateTime.Now.AddDays(2)
    });
}

当我在 OnNotificationFailed 中停止代理时捕获异常。在 PushSharp 和我的代码中,我使用 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 使用 .p12 证书进行 voip 通知,它已添加到 mmc 我的错误是什么?

【问题讨论】:

  • 我也有同样的问题。几天前一切正常。今天不是。你更新了windows 10吗?我做了...

标签: c# .net apple-push-notifications pushsharp


【解决方案1】:

我克隆 PushSharp repo,编译本地 dll,更改项目链接,它的工作,但我不知道为什么。

【讨论】:

    【解决方案2】:

    Nuget 中的包似乎与 Github 中的代码不是最新的。 Github 中的最新版本支持最近成为强制性的 TLS 1.2。因此,唯一的解决方案是克隆 repo,自己构建并添加对新构建的 DLL 的引用。

    【讨论】:

      【解决方案3】:

      临时修复:

      System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

      把它放在你的 application_startup 或 startup.cs 中

      【讨论】:

        猜你喜欢
        • 2016-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-25
        相关资源
        最近更新 更多