1

我让PushSharp成功向 Android、BB10 和 iOS 设备发送推送通知。我想向 WP8+ 设备发送通知,但似乎我没有成功注册 WindowsPhoneService。

这是我正在使用的代码:

PushBroker push = new PushBroker();
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;

push.RegisterWindowsPhoneService();

WindowsPhoneToastNotification windowsPhoneToastNotification = new    WindowsPhoneToastNotification()
    .ForEndpointUri(new Uri([[Device Uri]]))
    .ForOSVersion(WindowsPhoneDeviceOSVersion.Eight)
    .WithBatchingInterval(BatchingInterval.Immediate)
    .WithNavigatePath("/MainPage.xaml")
    .WithText1("Test 1")
    .WithText2("Test 2")
;

push.StopAllServices();

一切都非常简单,但不会发送通知,也不会触发任何事件。没有什么。我可以一直打断点到“push.StopAllServices();” 但在任何 PushSharp 相关事件中都没有任何断点。

我错过了什么?

4

1 回答 1

0

在最新版本的 PushSharp 中,有一个参数要传递给“StopAllService”,用于等待 stop 之前发送的队列:

// push.StopAllServices(true);

这将强制推送通道发送队列中的通知。

于 2015-04-17T09:21:40.583 回答