Push notification BackgroundTaskRegistration触发器属性为空

Push notification BackgroundTaskRegistration触发器属性为空,push-notification,win-universal-app,background-task,Push Notification,Win Universal App,Background Task,嗨,希望在后台任务上接收推送通知,因为我已经创建了可移植库。这里是我的后台任务类 using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using Windows.ApplicationModel.Background; u

嗨,希望在后台任务上接收推送通知,因为我已经创建了可移植库。这里是我的后台任务类

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Windows.ApplicationModel.Background;
using Windows.Data.Xml.Dom;
using Windows.Networking.PushNotifications;
using Windows.Storage;
using Windows.UI.Notifications;

namespace BackgroundTask
{
    public sealed class NotificationTask : IBackgroundTask
    {
        public void Run(IBackgroundTaskInstance taskInstance)
        {

            // Get the background task details
            ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
            string taskName = taskInstance.Task.Name;

            Debug.WriteLine("Background " + taskName + " starting...");

            // Store the content received from the notification so it can be retrieved from the UI.
            ToastNotification notification = (ToastNotification )taskInstance.TriggerDetails;
            settings.Values[taskName] = notification.Content;
            NotificationTask.AddTostNotification(notification.Content);

            Debug.WriteLine("Background " + taskName + " completed!");
        }



    private static void AddTostNotification(String xmlDocument)
    {

        List<string> messageSection = NotificationTask.GetMessageAndLandingPage(xmlDocument, "toast");

        if (messageSection == null) { return; }

        ToastTemplateType toastTemplate = ToastTemplateType.ToastText01;

        XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
        XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
        toastTextElements[0].AppendChild(toastXml.CreateTextNode(messageSection[0]));
        //  toastTextElements[1].AppendChild(toastXml.CreateTextNode(message));

        IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
        ((XmlElement)toastNode).SetAttribute("launch", messageSection[1]);

        XmlElement audio = toastXml.CreateElement("audio");
        audio.SetAttribute("src", "ms-appx:///Assets/Play-Guitar.wav");
        //audio.SetAttribute("loop", "true");
        toastNode.AppendChild(audio);

        //launch tost immediatly
        ToastNotification toast = new ToastNotification(toastXml);
        ToastNotificationManager.CreateToastNotifier().Show(toast);

    }
在我的清单文件中

  <Extensions>
    <Extension Category="windows.backgroundTasks" EntryPoint="BackgroundTask.NotificationTask">
      <BackgroundTasks>
        <Task Type="pushNotification" />
      </BackgroundTasks>
    </Extension>
  </Extensions>


PushNotification触发器未触发,调试时发现BackgroundTaskRegistration的触发器属性为null。问题是什么?这里到底出了什么问题?

有人可以就上述问题提供指导吗?我认为只有原始通知可以在后台支持,它可以与原始通知一起工作
  <Extensions>
    <Extension Category="windows.backgroundTasks" EntryPoint="BackgroundTask.NotificationTask">
      <BackgroundTasks>
        <Task Type="pushNotification" />
      </BackgroundTasks>
    </Extension>
  </Extensions>