Garmin makeWebRequest in background service delegate can not wake app from callback

865 views Asked by At

Trying to request a webrequest in the background, and trigger an application wake when it finishes. The example code works, but it's impossible to wake the app from a callback:

using Toybox.Background;
using Toybox.Communications;
using Toybox.System;

(:background)
class BackgroundService extends System.ServiceDelegate {

    function onTemporalEvent() {       
        Background.requestApplicationWake("do you want to open the app?"); 
        Background.exit(null);
    }
}

This does not work:

using Toybox.Background;
using Toybox.Communications;
using Toybox.System;

(:background)
class BackgroundService extends System.ServiceDelegate {

    function onTemporalEvent() {
        Communications.makeWebRequest(
            "https://jsonplaceholder.typicode.com/todos/1",
            {},
            {},
            method(:responseCallback)
        );
    }

    function responseCallback(responseCode, data) {
        Background.requestApplicationWake("do you want to open the app?");       
        Background.exit(null);
    }
}
0

There are 0 answers