Notifications and background activity

Yes, of course, everyone wants that...
How long and how often should your process run? The longer and the more often ir runs, the more likely that it will be killed by the operating system if you use background service

You ignored the other parts from the documentation

  1. Background Service: A non-visible background work that can be scheduled using Itoo.
  • Runs silently without user noticing it.
  • Vulnerable to being stopped by the system abruptly, can only run upto a few minutes in modern devices depending on the phone brand, OEM, OS installed, etc. (also see dontkillmyapp.com )
  1. Foreground Service: A user visible and recommended way to execute something in the background.
  • Itoo is primarily based on supporting this service.**
    .

Taifun

I have an application that reads data from the database(about power/electricity state) , and shows a notification if the electricity is down.
I can check for that every 1 minute or 2 at maximum. I don't know if this can be done
Whats your opinion Sir.?
Any advices.?

yes, this is very often... so use Foreground Service
Taifun

Okay, i will try it, do you have a simple example to use a foreground service to achieve my goal?

also i tried the above blocks , and still got the same error.
notice that I am building the project not using companion

What error?

That is error with your credential configuration.

I changed the info in the green box in the blocks image I attached, so I got another error:
"CloudDBError: javax.net.ssl.SSLException: Unable to parse TLS packet header"
I don't know how to solve it
another questions please , I still don't understand how this code/blocks, will help me

As I said earlier, your configuration is incorrect.

This should be full Cloud DB url, this is incorrect.

sorry I forgot to attach the blocks
here they are

Alright, does it work for you if you use the default credentials?

it worked with no errors while using default credentials.
with respect to my credentials , when I changed the property "Redis Server" to "DEFAULT" I got no error. but I see no change in the Redis Database data.
another questions please , I still don't understand how this code/blocks, will help me ?
I mean , what is the purpose of these blocks , supposing that they worked correctly

Every 5 seconds they store the text
Meow, Kumaraswamy!
in your database

Taifun

but that's not what I need
I need to read values from a database , and to process that data
for example : I read from a database the variable x , if x is true , then show a notification that x is true , and if it's false for example for 10 minutes , a notification is shown about that.
but I need all of this to be done without necessarily that the app is opened.
I hope you got my idea clear. Thank you

Set the values at the very bottom to false if you not use mit server

2 Likes

Well, it is an example how to connect to CloudDB in the background
Of course it is not exactly what you need
Now it is your turn to adjust it to your needs

Taifun

Thank you for your help ,
But still indeed , the blocks not working well , I will try to solve that , if not I will be back here
but what I need is to send notifications in the background. I am really sorry I still didn't find how to relate that

Staet again reading from here

Taifun

1 Like

This made the code to work , many thanks

1 Like