Windows 10 Mobile (10.0.14393) Background task for Geofence (LocationTrigger)

Since 10.0.14393 (Anniversery Update), LocationTrigger doesn't seem to work. I have:

  • Windows Phone 8.1 application (also applies to UWP application).
  • A portable library that displays the Windows Runtime Component ( .winmd ) .winmd
  • Declaration of a background task with location capabilities (set to the library as a record).
  • Access with BackgroundExecutionManager.RequestAccessAsync()
  • A LocationTrigger type Geofence .

The background task never starts. Registration / task code after gaining 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. } } 

Works on a device or Windows Phone 8.1 emulator. A preliminary update, it also worked on Windows 10 Mobile. Are there any known solutions so far?

+4
c # windows-phone cordova uwp windows-10-mobile
source share
1 answer

I also have such a problem, but with a simple TimeTrigger task. The task is registered without any errors, it is visible in the "Life Cycle Events" in Visual Studio, but it does not start at the scheduled time. Usually, but not always, the following steps help.

  • Deny access to the application to run in the background in the Windows settings.
  • Restart device
  • Allow access
  • Launch the task registration application

The problem will begin after updating the Universal Windows App development tools to version 1.4.1, but I'm not sure about that.

0
source share

All Articles