c# - PushSharp WithCustomItem 发送失败

标签 c# apple-push-notifications pushsharp

我的 Android 和 Apple 推送通知与 PushSharp 配合使用,但我无法通过 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) 您是否在 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) 可能是声音文件名错误。我看到它没有扩展名。

关于c# - PushSharp WithCustomItem 发送失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16888115/

相关文章:

c# - 中继器 - 在 "content"中带有滚动条的固定页眉和固定脚

ios - 如果为同一设备卸载/重新安装应用程序,设备 token 是否会更改

c# - PushSharp 关注点分离

C# ReadOnlySpan<char> 与用于字符串剖析的子字符串

c# - 创建大量任务/线程并等待它们全部完成

c# - .NET 字典中的元素是连续的吗?

ios - 推送通知传递和关闭回调

ios - 我可以在 didReceiveRemoteNotification : while app is in the background/suspended? 中执行操作吗

ssl - PushSharp APNS 生产 : The credentials supplied to the package were not recognized (development works fine though)

ios - PushSharp ApplePushService 给出 channel 异常