Parse platform 应用程序处于后台时,后台任务未注册且代码不工作

Parse platform 应用程序处于后台时,后台任务未注册且代码不工作,parse-platform,push-notification,windows-phone-8.1,background-task,Parse Platform,Push Notification,Windows Phone 8.1,Background Task,我使用parse发送推送通知,它工作得很好,但是在后台,即当应用程序未运行时,会执行注册后台服务的代码,但是没有设置任何任务,并且在收到通知后不会执行后台任务。请帮忙 下面是注册后台任务的代码 Debug.WriteLine("Registering task"); var taskRegistered = false; var exampleTaskName = "BackgroundTask";

我使用parse发送推送通知,它工作得很好,但是在后台,即当应用程序未运行时,会执行注册后台服务的代码,但是没有设置任何任务,并且在收到通知后不会执行后台任务。请帮忙

下面是注册后台任务的代码

Debug.WriteLine("Registering task");
                var taskRegistered = false;
                var exampleTaskName = "BackgroundTask";

                foreach (var task in BackgroundTaskRegistration.AllTasks)
                {
                    if (task.Value.Name == exampleTaskName)
                    {
                        taskRegistered = true;
                        task.Value.Unregister(true);
                        break;
                    }
                }

                await BackgroundExecutionManager.RequestAccessAsync();
                if (!taskRegistered)
                {
                    Debug.WriteLine("Registering task inside");
                    var builder = new BackgroundTaskBuilder();
                    builder.Name = exampleTaskName;
                    builder.TaskEntryPoint = "Tasks.BackgroundTask";
                    builder.Name = "PushNotification";
                    builder.SetTrigger(new Windows.ApplicationModel.Background.PushNotificationTrigger());
                    BackgroundTaskRegistration task = builder.Register();
                    await BackgroundExecutionManager.RequestAccessAsync();                        
                }
在后台执行的代码:

public async void Run(IBackgroundTaskInstance taskInstance)
    {
        Debug.WriteLine("1");
        BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();
        RawNotification notification = (RawNotification)taskInstance.TriggerDetails;
        string content = notification.Content; 
        Debug.WriteLine("2");
        _deferral.Complete();

    }

你在清单文件中添加了背景任务类了吗?是的,我在清单文件中添加了背景任务类。