【问题标题】:PushSharp doesn't send notificationsPushSharp 不发送通知
【发布时间】:2014-06-09 13:07:18
【问题描述】:

我有一个简单的代码:

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}}}

【问题讨论】:

    标签: c# push-notification apple-push-notifications pushsharp


    【解决方案1】:

    您的设备令牌不应包含任何空格和“”字符。它应包含 64 个十六进制字符。如果不是,则说明第一个错误(无效的令牌大小)。

    即, 不是&lt;3948de8f 3948de8f ...&gt; 也不是3948de8f 3948de8f ...

    仅限3948de8f3948de8f...

    第二个错误(无效令牌)可能意味着您使用沙盒设备令牌推送到生产 APNS 服务器,反之亦然。沙盒令牌只能在沙盒环境中使用。

    【讨论】:

    • 它对我有用。 “空格”对我来说是个问题。
    • 谢谢,它对我有用。 Sanbox 设备令牌对我来说是个问题
    • 你先生...刚刚结束了我漫长的一天!非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多