尝试在后台请求 webrequest,并在完成时触发应用程序唤醒。示例代码有效,但无法从回调中唤醒应用程序:
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);
}
}
这不起作用:
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);
}
}