Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot register GattCharacteristicNotificationTrigger Background Task after Creators Update

The background task registration code looks like this:

var builder = new BackgroundTaskBuilder();
builder.Name = name;
builder.TaskEntryPoint = typeof(BackgroundTaskClass).FullName;
var trigger = new GattCharacteristicNotificationTrigger(characteristic);
builder.SetTrigger(trigger);
btr = builder.Register();

The entry in the manifest is:

<Extension Category="windows.backgroundTasks" EntryPoint="BackgroundTaskNS.BackgroundTaskClass">
  <BackgroundTasks>
    <Task Type="deviceConnectionChange" />
    <Task Type="bluetooth" />
  </BackgroundTasks>
</Extension>

The Register() method triggers this error:

Access is denied.

Your App does not have permission to use the Gatt Service in the background. Make sure you have declared the DeviceCapability and Task Type 'bluetooth' in your manifest and that the application has been granted access to this device.

This only happens on Creators Update installed on the build machine and also targeting the Creators Update SDK. This worked well before we updated the SDK and the build machine.

like image 487
Tyress Avatar asked Apr 20 '17 06:04

Tyress


Video Answer


3 Answers

We've had the same issue with UWP app on windows 10 mobile.

We updated windows 10 mobile to build 10.0.15230.0, then deleted the app (manually on a phone) and installed it again. Now it works fine. Also we installed last version of SDK, but I think this step can be skipped.

like image 120
Stanislav Mayorov Avatar answered Oct 10 '22 12:10

Stanislav Mayorov


In the compatibility section of your manifest, add this:

<Capabilities>
   <DeviceCapability Name="bluetooth" />
</Capabilities>
like image 41
Kodaloid Avatar answered Oct 10 '22 14:10

Kodaloid


Didn't see it in your code sample. Could be that you need to call RequestAccessAsync from a UX thread on the GattDeviceService which contains the characteristic before registering your trigger.

like image 1
MarkovskI Avatar answered Oct 10 '22 12:10

MarkovskI