【问题标题】:Push Notification inside ScheduledAgent in Windows Phone 8在 Windows Phone 8 中的 ScheduledAgent 内推送通知
【发布时间】:2021-06-17 21:09:08
【问题描述】:

我想完成一个类似的任务,我想使用后台代理重新建立我的推送通知通道。有可能吗?

我在我的 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();
    }

【问题讨论】:

    标签: windows-phone-7 windows-phone-8 push-notification mpns background-agent


    【解决方案1】:

    根据Unsupported APIs in Background Agents 的列表,无法在Microsoft.Phone.Notification 命名空间中执行任何操作,其中包括与来自计划代理的推送通知有关的所有内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多