質問

I would like to achieve a similar task, in which I want to re-establish my push notification channel using background agent. Is it possible?

I am using the following code inside my ScheduledAgent, but its not working. If I cannot access the channel APIs, is there any alternative to that? How have popular apps like whats-app and others been able to achieve this? Please help me.

Can you advise me an alternative? How can I update my user that there is something new for him from my server without using this approach?

    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();
    }
役に立ちましたか?

解決

As per the list of Unsupported APIs in Background Agents, it is not possible to do anything in the Microsoft.Phone.Notification namespace, which includes everything to do with push notifications, from a scheduled agent.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top