我有一个简单的代码:
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);
我尝试分别使用沙箱和生产服务器的开发和生产证书。但什么也没发生。客户端能够获取推送通知。
怎么了?提前致谢。
UPDATED:
我订阅了这些活动。
OnNotificationFailed 告诉我这个错误:
{APNS NotificationFailureException -> 5 : Invalid token size -> {"aps":{"badge":1}}}
如果我将设备令牌包装到 <...> 中,我会收到另一个错误:
{APNS NotificationFailureException -> 8 : Invalid token -> {"aps":{"badge":1}}}
您的设备令牌不应包含任何空格和“”字符。它应包含 64 个十六进制字符。如果没有,那就解释了第一个错误(令牌大小无效)。
IE,
不是<3948de8f 3948de8f ...>
nor 3948de8f 3948de8f ...
Only 3948de8f3948de8f...
第二个错误(无效令牌)可能意味着您使用沙箱设备令牌推送到生产 APNS 服务器,反之亦然。沙箱令牌只能在沙箱环境中使用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)