Windows 10 Mobile(10.0.14393)地理栅栏的背景任务(LocationTrigger) [英] Windows 10 Mobile (10.0.14393) Background Task for Geofence (LocationTrigger)

查看:180
本文介绍了Windows 10 Mobile(10.0.14393)地理栅栏的背景任务(LocationTrigger)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

10.0.14393 (Anniversery更新)后, LocationTrigger 似乎无法正常工作。我有:

Ever since 10.0.14393 (Anniversery Update), LocationTrigger does not seem to work. I have:


  • Windows Phone 8.1应用程序(也适用于UWP应用程序)。

  • 输出到 Windows Runtime组件库( .winmd )的便携式库

  • 具有位置功能的后台任务的声明(设置为图书馆条目)。

  • 使用 BackgroundExecutionManager.RequestAccessAsync()

  • LocationTrigger / code>。

  • A Windows Phone 8.1 application (also applies to a UWP application).
  • A portable library that ouputs to a Windows Runtime Component library (.winmd)
  • A declaration of Background Task with Location capabilities (set to the library as entry).
  • Access with BackgroundExecutionManager.RequestAccessAsync()
  • A LocationTrigger of type Geofence.

后台任务从未被触发。获取访问权限后的注册/任务代码:

The background task is never triggered. Registration/task code after obtaining access:

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移动。目前有什么已知的解决方案?

Running on a Windows Phone 8.1 device or emulator works. Pre-update, it worked on Windows 10 Mobile, too. Is there any known solutions so far?

推荐答案

我也有这样的问题,但简单的TimeTrigger任务。任务注册没有任何错误,它在Visual Studio的生命周期事件中可见,但它不是在预定的时间启动。通常,但不总是,有助于下一步。

I'm also having such issue but with simple TimeTrigger task. Task registered without any error, it visible in "Lifecycle Events" of Visual studio, but it not starts at scheduled time. Usually, but not always, helps next steps.


  1. 拒绝应用程式在Windows设定的后台运行

  2. 重新启动设备

  3. 允许访问

  4. 运行应用注册任务

  1. Deny access to the app to run in background in Windows settings
  2. Restart device
  3. Allow access
  4. Run app to register tasks

问题已经开始发生更新后的通用Windows应用程序开发工具到版本1.4.1,但我不知道这一点。

The issue have start happen after update of Universal Windows App development tools to version 1.4.1, but I'm not sure on that point.

这篇关于Windows 10 Mobile(10.0.14393)地理栅栏的背景任务(LocationTrigger)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆