我使用解析来发送推送通知并且其工作正常但是,在后台,即,当应用程序未运行时,则执行注册后台服务的代码,但是没有设置任务和后台收到通知后不执行任务。请帮忙!!
以下是注册后台任务的代码
10,32,"Afghanistan","Afghanistan","Various organizations" ..
在后台执行的代码:
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();
}