加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – PushSharp APNS通知错误不支持请求的功能

发布时间:2020-12-15 22:55:28 所属栏目:百科 来源:网络整理
导读:我正在使用PushSharp 4.0.10 在Apns代理的OnNotificationFailed事件中,我得到“不支持请求的功能”异常.有我的经纪人创建者 private static ApnsServiceBroker CreateApnsBroker(string certificate){ // Configuration (NOTE: .pfx can also be used here)
我正在使用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格式添加
我的错是什么?

解决方法

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读