PushSharp不会发送通知
我有一个简单的代码:
PushBroker pushBroker = new PushBroker(); string path = HttpContext.Current.Server.MapPath("~/" + AppSettings.CertificatePath); var appleCert = File.ReadAllBytes(path); pushBroker.RegisterAppleService( new ApplePushChannelSettings(AppSettings.IsProductionPushNotificationServer, appleCert, AppSettings.CertificatePassword)); var notification = new AppleNotification().ForDeviceToken(deviceToken.TrimStart('')) .WithBadge(unviewedInvitationCount); pushBroker.QueueNotification(notification);
我尝试分别使用Sandbox和Production服务器的开发和生产sertificates。 但什么都没发生。 客户端能够获得推送通知。 怎么了? 提前致谢。
更新:
我订阅了这些活动。
OnNotificationFailed告诉我有关此错误的信息:
{APNS NotificationFailureException -> 5 : Invalid token size -> {"aps":{"badge":1}}}
如果我将设备令牌包装到中,我会收到另一个错误:
{APNS NotificationFailureException -> 8 : Invalid token -> {"aps":{"badge":1}}}
您的设备令牌不应包含任何空格和“<”或“>”字符。 它应包含64个hex字符。 如果没有,则说明第一个错误(令牌大小无效)。
即,不是<3948de8f 3948de8f ...>
也不是3948de8f 3948de8f ...
只有3948de8f3948de8f...
第二个错误(无效令牌)可能意味着您使用沙盒设备令牌推送到生产APNS服务器,反之亦然。 沙箱令牌仅用于沙盒环境中。
上述就是C#学习教程:PushSharp不会发送通知分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1022072.html