如何触发OnDeviceSubscriptionExpired
本文关键字:OnDeviceSubscriptionExpired 何触发 | 更新日期: 2023-09-27 18:12:05
我有一个标准的pushsharp代码,看起来像下面的
PushBroker push = new PushBroker();
var appleCert = File.ReadAllBytes(@"myp12.p12");
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "password"));
push.QueueNotification(new AppleNotification()
.ForDeviceToken(mydevice)
.WithAlert("hello world")
.WithBadge(1)
.WithSound("default")
.WithCategory("INVITE_CATEGORY")
.WithCustomItem("custom-item", "i'm so cool"));
push.StopAllServices();
我可以发送推送通知。在正确的时间调用适当的事件。
我想测试的是当苹果告诉我这个特定的订阅已经过期时将会发生的逻辑。我附加了事件,但似乎无法调用它。它看起来差不多是这样的
static void DeviceSubscriptionExpired(object sender, string expiredDeviceSubscriptionId, DateTime timestamp, INotification notification)
{
//logic that deactivates subscription in database
}
如何触发此事件?
我想我可以删除应用程序,然后尝试发送多个通知到这个设备。但这似乎不起作用。
我错过了什么?
我不认为这个事件可用于iOS。在我与PushSharp合作的两年中,苹果唯一返回的事件是ServiceException。但从谷歌我收到DeviceSubscriptionExpired和DeviceSubscriptionChanged.