我有一个简单的密码:
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('<').TrimEnd('>'))
.WithBadge(unviewedInvitationCount);
pushBroker.QueueNotification(notification);我尝试使用开发和生产服务分别与沙箱和生产服务器。但什么都没发生。客户端能够获得推送通知。怎么了?提前谢谢。
更新:
我订阅了这些活动。
OnNotificationFailed告诉我这个错误:
{APNS NotificationFailureException -> 5 : Invalid token size -> {"aps":{"badge":1}}}如果我将设备令牌封装到<...>中,则会收到另一个错误:
{APNS NotificationFailureException -> 8 : Invalid token -> {"aps":{"badge":1}}}发布于 2014-04-24 12:37:18
您的设备令牌不应该有任何空格和'<‘或’>字符.它应该包含64个十六进制字符。如果没有,这就解释了第一个错误(无效的令牌大小)。
也就是说,不是<3948de8f 3948de8f ...>也不是3948de8f 3948de8f ...
只有3948de8f3948de8f...
第二个错误(无效令牌)可能意味着您使用沙箱设备令牌推送到生产APNS服务器,反之亦然。沙箱令牌shuold只用于沙箱env。
https://stackoverflow.com/questions/23265653
复制相似问题