87
Views
2
Comments
Solved
How to make push notifications based on regular (every 5 minutes) GET API requests?
Application Type
Mobile

I have an application that displays transport information based on which department/branch the user is working in.

The next task: every five minutes to check whether new records have appeared in the database (only for the user's branch). We do this by sending the API with a "branch number" parameter and it returns a boolean variable. And if it's "true" (a new record appeared), I need to send a push notification. The "OneSignal" plugin is installed for notifications. 

And this process should work in background mode.

I tried to implement this with timers, but they don't accept client variables (branch number) and client actions(like GetDeviceID for notification). The only solution I can see is to plug in the javascript.

I am new to Outsystems, please tell me how to solve this problem? Maybe someone had a similar experience.

2020-07-29 19-08-40
Sanjay Kumar Sahu
Solution

Hello Darina,


I think calling a server action in every 5 mins will solve, for this purpose you can use below JS code on OnInitialize event:

setInterval(function () {  $actions.SetAlert();}, 300000);      -- 5 Mins

Then call your DB action on SetAlert() like below:

Hope it helps!

2026-01-19 15-49-48
Ankit Gangrade
Champion

If it is a mobile application you can also utilize the background sync mechanism. 

Just trigger the background sync mechanism in every 5 min from the generic logic flow, you can call the function from javascript. 

It will then work in background mode, will go to server and give back the response. once it gets finish it automatically trigger the OnSyncComplete or OnSyncError event. 

You can handle that events in every screen and write you business logic in that event handlers. 

2020-07-29 19-08-40
Sanjay Kumar Sahu
Solution

Hello Darina,


I think calling a server action in every 5 mins will solve, for this purpose you can use below JS code on OnInitialize event:

setInterval(function () {  $actions.SetAlert();}, 300000);      -- 5 Mins

Then call your DB action on SetAlert() like below:

Hope it helps!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.