I'm having an issue setting up a temporal event. I keep getting the following error even though I've had this exact code set up present on a data field with success. Am I missing something when implementing within an App.
Error: Illegal Access (Out of Bounds)
Details: Failed invoking <symbol>
Stack:
- onStart() at [line 46]
(line 46 is the onStart() function in the App base)
I register for a temporal event in initialize, and everything runs fine until it executes.
Then I get a System Error
******
I make the call to register in my app base.
class myApp extends Application.AppBase {
function initialize() {
...
regTempEvent();
...
}
...
}
I register here in this function
//register for temporal events if supported
function regTempEvent(){
if (Toybox.System has :ServiceDelegate) {
canDoBG = true;
Background.registerForTemporalEvent(new Time.Duration(5*60));
}
}
Here is my Background Class
using Toybox.Application as App;
using Toybox.System;
using Toybox.Background;
using Toybox.Communications;
(:background)
class BgServiceDelegate extends System.ServiceDelegate {
function initialize() {
System.ServiceDelegate.initialize();
}
// callback function
function onReceive(responseCode, data) {
if (data == null) {
data = {};
}
data["responseCode"] = responseCode;
Background.exit(data);
}
function makeRequest() {
if (Communications has :makeWebRequest) {
var url = Lang.format("url stuff");
var options = {
:method => Communications.HTTP_REQUEST_METHOD_GET,
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
};
Communications.makeWebRequest(
url,
{},
options,
method(:onReceive)
);
}
}
function onTemporalEvent() {
makeRequest();
}
}