Background timer and notification APP

Hi, I’m monitoring the connection status of an ESP8266 and displaying on the label whether it is “online” or whether it is “offline”. If the ESP8266 is offline for more than 5 minutes, “offline” is displayed.
Everything works fine, but only when the app is open.
Instead, I would like to implement a feature that allows me to receive a notification on the app when the ESP8266 goes offline. How can I create it? Should the timer continue to run in the background? If yes, how can I do it?

read this
https://community.kodular.io/t/itoo-background-tasks-special

Hi, yes I had seen it but I can’t understand how to start the timer in the background, the examples are from previous versions and are different from the current one.
How do I set call.Itoo1.RegisterEvent based on the timer I have?
Immagine
Immagine1

You have to write an event handler, which looks like a procedure and put the same blocks inside as you currently have in your ClockStato.Timer event

Also setup itoo correctly for Firebase background processing…

Taifun

Read the first post about how to use itoo

and don’t use global variables in the background

Taifun

Do you know if there is any other way to create background tasks? I can’t figure out how to make itoo work.

There is no other way
Follow the usage tips

Usage

  • Before you try to do something with Itoo, first get it working normally.
  • Do not use global variables, or try to access/set them.
  • Do not use user interface components such as Label, TextBox or even Notifier since there is no interface in background.
  • You cannot use Tiny DB, alternatively you are supposed to make use of the similar storage features Store/Fetch property blocks offered by this extension.
  • For the main background procedure, you need to include an argument “x”.
  • You cannot use normal Event blocks in background, use RegisterEvent block to listen to component events.
  • You cannot run more than one foreground or background service.
  • A component does not get created until you touch any of its block.

And if you need help, what about providing a screenshot of your relevant blocks?

Taifun

1 Like

Ok Thanks.

Unfortunately I don’t understand how to use this extension, I’m willing to pay with PayPal if someone can edit my .aia.

Basically I have to receive a message when the device is Offline.
This already happens correctly but only when the app is open.
the goal is that even if the user DOES NOT open the app and the device goes offline a notification must be sent.
I tried to create it but it’s definitely wrong.

probably @Xoma is able to help
Taifun

Thanks Taifun :+1:

I was able to get the extension working properly in the background thanks to Xoma. However, I’ve noticed that I can’t read what’s happening in the background on Got.Value. When I call Get.Value in the notification procedure, I cannot get the response, because it is located on Got.Value. Does anyone know how I can solve this problem?

Yes, it is always like this in asynchronous processing… you have to register the GotValue event and do your processing in the got value event handler…

Remember, events do not work in the background, therefore you have to register a corresponding event handler as you did for the Clock Timer event

Taifun

In this way ?

The event handler for the GotValue event must have the same arguments as the event…
Akso I would call that event handler different. . What about gotValue instead of notification2?
How do you set property timeDifference? I would use a reasonable integer value for the tagIfValueNotThere socket instead of an empty text block

Taifun

Thanks for your advice, it seems that the notification is now received correctly in the background.