Ticket Created
over 4 years ago

WERETECH-10902

callback in makeWebRequest in background never called

Environment:

Venu (physical and simulator)

Connect IQ 3.2.4

Eclipse: 4.17.0


Here are two examples of background service delegates:

This example triggers the user to be notified about opening the app

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, it seems the background task exits without the callback finishing:

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);
    }
}


Thank you!