我有一个标准的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
}如何触发此事件?
我想我可以删除这个应用程序,然后尝试向这个设备发送多个通知。但这似乎不起作用。
我遗漏了什么?
发布于 2015-12-16 23:23:17
我不认为这个活动对iOS是可用的。在我使用PushSharp的两年时间里,从苹果返回的唯一事件就是ServiceException。但我从谷歌那里收到了DeviceSubscriptionExpired和DeviceSubscriptionChanged。
https://stackoverflow.com/questions/32489753
复制相似问题