Windows 10 Mobile(10.0.14393)地理围栏的后台任务(LocationTrigger)

自从10.0.14393 (Anniversery Update)以来, LocationTrigger似乎不起作用。 我有:

  • Windows Phone 8.1应用程序(也适用于UWP应用程序)。
  • 一个可输入Windows Runtime Component库的可.winmd库( .winmd
  • 具有位置function的后台任务声明(设置为库作为条目)。
  • 使用BackgroundExecutionManager.RequestAccessAsync()访问
  • Geofence类型的LocationTrigger

后台任务永远不会被触发。 获取访问权限后的注册/任务代码:

 public sealed class GeofenceTask : IBackgroundTask { public static void Register() { var taskName = nameof(GeofenceTask); foreach (var n in BackgroundTaskRegistration.AllTasks.Where(n => n.Value.Name == taskName)) { n.Value.Unregister(true); break; } var builder = new BackgroundTaskBuilder {Name = taskName, TaskEntryPoint = typeof (GeofenceTask).FullName}; builder.SetTrigger(new LocationTrigger(LocationTriggerType.Geofence)); builder.Register(); } public void Run(IBackgroundTaskInstance taskInstance) { // Do magic. } } 

在Windows Phone 8.1设备或模拟器上运行。 预更新,它也适用于Windows 10 Mobile。 到目前为止有没有已知的解决方案?

我也遇到了这样的问题,但是使用简单的TimeTrigger任务。 任务注册没有任何错误,它在Visual Studio的“生命周期事件”中可见,但它不会在预定的时间启动。 通常,但并非总是如此,有助于后续步骤。

  1. 拒绝访问应用程序以在Windows设置中在后台运行
  2. 重启设备
  3. 允许访问
  4. 运行应用程序以注册任务

在将通用Windows应用程序开发工具更新到版本1.4.1后,问题已经开始,但我不确定这一点。