不为WP8触发PushSharp事件

时间:2014-06-17 13:32:14

标签: windows-phone-8 notifications pushsharp

我已成功向Android,BB10和iOS设备发送推送通知PushSharp。我想向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相关的事件中的任何断点。

我错过了什么?

1 个答案:

答案 0 :(得分:0)

在最新版本的PushSharp中,有一个参数传递给" StopAllService"等待在停止之前发送的队列:

// push.StopAllServices(真);

这将强制pushchannel在队列中发送通知。