PushSharp WithCustomItem无法发送

时间:2013-06-02 23:01:25

标签: c# apple-push-notifications pushsharp

我有使用PushSharp的Android和Apple推送通知,但我在使用Apple通知发送自定义数据时遇到问题。

完美发送:

push.QueueNotification(new AppleNotification()
                                   .ForDeviceToken(device.Identifier)
                                   .WithAlert(message)
                                   .WithSound("default")
                                   .WithBadge(7));

这根本不起作用:

push.QueueNotification(new AppleNotification()
                                   .ForDeviceToken(device.Identifier)
                                   .WithAlert(message)
                                   .WithSound("default")
                                   .WithCustomItem("incidentId", new[] { 1 })
                                   .WithBadge(7));

后者永远不会遇到NotificationSent,NotificationFailed,ServiceException等,并且永远不会进入手机。

使用PushSharp版本2.0.4.0

我是否在尝试添加自定义数据时出错?

1 个答案:

答案 0 :(得分:5)

1)您是否在ApplePushChannelSettings中设置了生产环境(而不是沙箱)?

//Create our push services broker
var push = new PushBroker();

//Registering the Apple Service and sending an iOS Notification
var appleCert = File.ReadAllBytes("YourCert.p12"));

//isProduction - development or ad-hoc/release certificate
push.RegisterAppleService(new ApplePushChannelSettings(isProduction, appleCert, "pwd"));

2)尝试使用

WithCustomItem("incidentId", "1");

3)可能原因是声音文件名错误。我看到它没有扩展名。