【发布时间】:2016-08-26 13:47:11
【问题描述】:
自从10.0.14393(周年纪念更新)以来,LocationTrigger 似乎不起作用。我有:
- Windows Phone 8.1 应用程序(也适用于 UWP 应用程序)。
- 输出到
Windows Runtime Component库 (.winmd) 的可移植库 - Background Task 的声明具有 Location 功能(设置为库作为条目)。
- 使用
BackgroundExecutionManager.RequestAccessAsync()访问 -
LocationTrigger类型为Geofence。
永远不会触发后台任务。获取权限后的注册/任务码:
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 移动版。到目前为止有没有已知的解决方案?
【问题讨论】:
-
您是否检查过样本是否有任何差异(尤其是如果样本在您的设备上按预期工作)? github.com/Microsoft/Windows-universal-samples/tree/master/…
-
该示例也无法按预期工作@MZetko(在 10.0.14393 上)
-
我们正在调查此问题,感谢您的报告
标签: c# cordova windows-phone uwp windows-10-mobile