Early makeWebRequest in a data field?

So data field apps are pretty constrained. It's possible to schedule a temporal event after 5 minutes that will conduct a web request in a background context. Any earlier (like with no delay) will result in an exception: Background event period cannot be less than 5 minutes.

However, I feel like it might be possible to somehow overcome this? My presumption is based on one app I can see in the app store - the problem is that I have an aging FR945 and can't install apps with modern SDK levels to validate this for myself.

TLDR: On devices running modern SDKs (after API level 3.3), is it possible to invoke a makeWebRequest (via a background process or otherwise) in a data field any earlier than 5 minutes after init?

  • You can perform the BG web request immediately upon starting the app! As long as you haven't run the app recently and break the 5 min wait delay.... Make sense? You can check the last time it was run to prevent this. But, yes, as long as the 5 min delay is respected, run it at start up.

  • Thanks for the reply.    Does this apply for data fields? I can't seem to make it work on my device. Here's what I've tried (amongst other things):

    1. Upload brand new data field .prg to the device,

    2. Add the data field to an activity,

    3. The Background.registerForTemporalEvent(), run in the app's initialize(), is given an argument of Time.now(), since it's not been run before.

    This throw an exception in the way I first described.

    On which device(s) do you know this works?

  • I do this in my data fields on all EDGE and Watch devices. I differentiate between the older devices that require the background processing, vs the new devices that can do it as often as desired in the foreground.

  • 3. The Background.registerForTemporalEvent(), run in the app's initialize(), is given an argument of Time.now(), since it's not been run before.

    Call registerForTemporalEvent with a Duration, not a Moment. If the event hasn't run in the last 5 minutes, it should run immediately. 

    Background.registerForTemporalEvent(new Time.Duration(5 * 60));

    This form of the call specifies a temporal event that repeats every 5 minutes, it doesn't specify that the next event will happen 5 minutes from now.

    Also, you may need to call Background.deleteTemporalEvent() in your app's onStop() method.

    Yeah, I'm aware that API doc example suggests the opposite - passing "now + 5 minutes" to registerForTemporalEvent, but I don't think it's a great example.