我想完成一个类似的任务,我想使用后台代理重新建立我的推送通知通道。是否可以?
我在 ScheduledAgent 中使用以下代码,但它不起作用。如果我无法访问通道 API,是否有任何替代方法?whats-app 等流行应用程序是如何实现这一目标的?请帮我。
你能给我一个替代方案吗?在不使用这种方法的情况下,如何向我的用户更新我的服务器上的新内容?
protected override void OnInvoke(ScheduledTask task)
{
//TODO: Add code to perform your task in background
HttpNotificationChannel pushChannel = HttpNotificationChannel.Find("HikeApp");
if (pushChannel == null)
{
pushChannel = new HttpNotificationChannel("HikeApp");
// Register for all the events before attempting to open the channel.
pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
pushChannel.Open();
pushChannel.BindToShellTile();
pushChannel.BindToShellToast();
}
else
{
// the channel was already open, so just register for all the events.
pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
}
#if DEBUG_AGENT
ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(1));
#endif
NotifyComplete();
}