Android Question Best way to organize a Price Alert ( Background )

tufanv

Expert
Licensed User
Longtime User
Hello,

I have a live exchange rate tracking app. Users request to have a price alert option so if the price rises or falls above/below a specific price , they want to get a notification.

I can think of 2 ways :

1) Check price on background and alert ( this is not good for me as I have many users using the app , this will overload the server )
2) maybe send the alarms set by users to a database , check them on the server every 5 seconds , send notification using firebase to user. This seems more logical.

Is there any better way you can suggest ? If not , is the second option is good enough to achieve this ? I would like to hear your ideas.

Thanks
 

udg

Expert
Licensed User
Longtime User
Hi,
I think it depends on how you tooled your current app.
If the autheticated user receives at given intervals an update of rating data then you can let her/him set locally her/his own thresholds.
If current mobile app it's just "a window" on a dynamic page on the server (so no raw data is transmitted to the user) you have to manage the thresholds for the alerts on the server.
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
FCM is very reliable (WhatsApp and Facebook uses it, too). On your server run a cron job every x secs to check the prices (or it's triggered by one of the other tasks crawling the prices). You already handle the users in a db I assume so it's just a small edit of the code to handle the devices/tokens. It's a big benefit to group all the users by subscribing to a topic (like for a special item). FCM handles all automatically.
 
Upvote 0
Top