Reputation: 1053
The first Application Trigger call within the app works as expected, I hit the first break point in background task (entry point) after the following code (result is "allowed"):
applicationTrigger.requestAsync(appParams).done(res => {
const resultKeys = Object.keys(Background.ApplicationTriggerResult);
console.debug(resultKeys[res]);
});
The subsequent calls during the course of my app run also show as "allowed" however the background task code is never called. I know this since the break point in the background task file is never hit and the XHR request in that background task is never called (it is only called on the first application trigger requestAsync call). The only way I can get it to successfully call multiple times is to un-register and re-register the application trigger associated task before making the call (which I feel like I shouldn't have to resort to this).
I have deferral.complete() in my background task code for when the async operation has completed as well, so that isn't the issue. I have also just tried waiting for two minutes before triggering again and it still does not run the task. The documentation for JavaScript UWP background tasks is a bit sparse, so if anybody can help me on this it would be greatly appreciated.
Upvotes: 0
Views: 151
Reputation: 1053
The issue was that I was not calling close in the background task web worker, which I just inferred was potentially the issue after reading the following (note highlighted in purple):
https://learn.microsoft.com/en-us/uwp/api/windows.ui.webui.iwebuibackgroundtaskinstance
For reference the call to close is simply:
close();
Upvotes: 0