Run promise ( http.get ) in background mode

hello every ionics,

i’m looking for a solution to execute a promise on background.
the need is to call $http.get every 5 secondes, when the application is on background.

thanks for help

I think you will run into problems with ios permissions.
Apple only allows location tracking and some special actions in background.
In other cases your app will be rejected.

You should also consider, that every background process costs battery life -> if you are really sending every 5seconds a requests it will drain your battary a little bit (like over night and so on).

Maybe it is enough, to have that interval when the app is active?
Because after 5seconds you put the app in foreground your new data will be updated?

Hello bengtler,
Thanks for feedback

I need the promise to asynchronously check new user task,
even if the app’s put into the background.
i can do that via push notif, but need to be sûre the promise do the job.

have a good day

i do not understand.
Send a push notification -> if the user clicks the notification -> app starts oder get back in forground or is already in forground.

If your push notification handling received a new notification -> call your promise function and get new tasks?
Why to do that in background, when the user does not use the app and does not see any new tasks.

@bengtler

i want something like this, don’t really need to be a promise, but i need to work in background mode
but with more spaced time, like minutes…

example of a app that can use similar behavior,

you are in gps with your car, you set a route and it estimate the time, than you can put it in background, and if something happens (like an accident or theft, or really anything) that make the estimate time change drastically the app send a new route optional route based on your gps,

so there is two options, keep asking every minute, 2 mins, 5 minutes or whatever, from background

or simple keep tracking in server and if needed send a push (obviously will be a lower battery drain)

and btw push notifications can trigger actions in an app?

well i’m not developing an app like this, but i will need a behaviour like this in my app so just asking