我有一个简单的代码:
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}}}