我有使用 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) 您是否在 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/