PushSharp不发送通知 [英] PushSharp doesn't send notifications

查看:263
本文介绍了PushSharp不发送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的code:

  PushBroker pushBroker =新PushBroker();
字符串路径= HttpContext.Current.Server.MapPath(〜/+ AppSettings.CertificatePath);
VAR appleCert = File.ReadAllBytes(路径);
pushBroker.RegisterAppleService(
           新ApplePushChannelSettings(AppSettings.IsProductionPushNotificationServer,
                                        appleCert,
                                        AppSettings.CertificatePassword));。VAR通知=新AppleNotification()ForDeviceToken(deviceToken.TrimStart('<')TrimEnd(。'>'))
                                          .WithBadge(unviewedInvitationCount);pushBroker.QueueNotification(通知);

我尝试使用分别与沙盒的研发和生产sertificates和生产服务器。但没有什么是发生了。客户端是能够得到推送通知。
怎么了?先谢谢了。

更新:

我订阅的事件。

OnNotificationFailed说我这个错误:

  {APNS NotificationFailureException  - > 5:无效的令牌大小 - > {APS:{徽章:1}}}

如果我换我的设备令牌进入< ...>我收到另一个错误:

  {APNS NotificationFailureException  - > 8:无效的标记 - > {APS:{徽章:1}}}


解决方案

您的设备令牌不应该有任何空格和'<'或'>'字符。它应该包含64个十六进制字符。如果没有,这解释了第一个错误(无效令牌大小)。

即,
没有< 3948de8f 3948de8f ...> 也不 3948de8f 3948de8f ...

只有 3948de8f3948de8f ...

第二个错误(无效标记)可能意味着你使用的沙箱设备令牌推到生产服务器APNS,反之亦然。沙盒令牌shuold只在沙盘ENV使用。

I have got a simple code:

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);

I try to use development and production sertificates with Sandbox and Production server respectively. But nothing is happened. Client side is able to get the push notifications. What's wrong? Thanks in advance.

UPDATED:

I subscribed on the events.

OnNotificationFailed says me about this error:

{APNS NotificationFailureException -> 5 : Invalid token size -> {"aps":{"badge":1}}}

And if I wrap my device token into <...> I receive another error:

{APNS NotificationFailureException -> 8 : Invalid token -> {"aps":{"badge":1}}}

解决方案

Your device token shouldn't have any spaces and '<' or '>' characters. It should contain 64 hexadecimal characters. If it doesn't, that explains the first error (invalid token size).

i.e, not <3948de8f 3948de8f ...> nor 3948de8f 3948de8f ...

Only 3948de8f3948de8f...

The second error (invalid token) probably means that you used a sandbox device token to push to the production APNS server or vice versa. Sandbox tokens shuold only be used in the sandbox env.

这篇关于PushSharp不发送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆