Nes*_*hta 7 c# push-notification apple-push-notifications 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('<').TrimEnd('>'))
.WithBadge(unviewedInvitationCount);
pushBroker.QueueNotification(notification);
Run Code Online (Sandbox Code Playgroud)
我尝试分别使用Sandbox和Production服务器的开发和生产sertificates.但什么都没发生.客户端能够获得推送通知.怎么了?提前致谢.
更新:
我订阅了这些活动.
OnNotificationFailed告诉我有关此错误的信息:
{APNS NotificationFailureException -> 5 : Invalid token size -> {"aps":{"badge":1}}}
Run Code Online (Sandbox Code Playgroud)
如果我将设备令牌包装到<...>中,我会收到另一个错误:
{APNS NotificationFailureException -> 8 : Invalid token -> {"aps":{"badge":1}}}
Run Code Online (Sandbox Code Playgroud)
Era*_*ran 20
您的设备令牌不应包含任何空格和"<"或">"字符.它应包含64个十六进制字符.如果没有,则说明第一个错误(令牌大小无效).
即,不是<3948de8f 3948de8f ...>
也不是3948de8f 3948de8f ...
只要 3948de8f3948de8f...
第二个错误(无效令牌)可能意味着您使用沙盒设备令牌推送到生产APNS服务器,反之亦然.沙盒令牌仅用于沙盒环境中.
归档时间: |
|
查看次数: |
6604 次 |
最近记录: |