I am fetching a data from an API, and I want to have a live update of display of data in my app when something changes in the data from the API. All I done is to have an interval that makes a request in the API every minute, and I think its not the best solution for this. Because it consumes a lot of power for the phone. So is there an alternative for this? The API that I am using is something external from us so we cannot change it to adjust for some solutions.
in background or foreground ?
Both sir because on the background I want to fetch some notification and on the foreground I want to display a live update of chart.
if your app in background after 5 min your app will be go sleep mode and you can not use any interval to send APi
so your battery will stay along time .
if u can send API in background tell me how did u do that ?
and you don’t need doing any think to fetch some notification
I am using the native backgroundmode. And I do not know if it is still running even when the phone is in sleep mode
try : run interval in app.ts and print any think to see
in ionic cordova run android