我有标准的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();
我可以发送推送通知。在正确的时间调用适当的事件。
我要测试的是Apple告诉我该特定订阅已过期时将发生的逻辑。我附加了 Activity ,但似乎无法调用它。看起来或多或少像这样
static void DeviceSubscriptionExpired(object sender, string expiredDeviceSubscriptionId, DateTime timestamp, INotification notification)
{
//logic that deactivates subscription in database
}
如何触发此事件?
我以为可以删除该应用程序,然后尝试向该设备发送多个通知。但这似乎不起作用。
我想念什么?
最佳答案
我认为此 Activity 不适用于iOS。在使用PushSharp的两年中,Apple返回的唯一事件是ServiceException。但是我从Google收到了DeviceSubscriptionExpired和DeviceSubscriptionChanged。
关于c# - PushSharp-如何触发OnDeviceSubscriptionExpired,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32489753/