简体   繁体   中英

Best way to detect changes in an API response

Hey so basically I have a school API that provides me some informations about current courses, homeworks, etc, and so they differs depending on the current time. I would like to build an Android application around that API that would send me a notification when there is a different course happening, or when i get a new homework or anything else.

So what is the best way to achieve this? I tought about making a loop that will send a request to the API every x secondes/minutes and if it retrieves different informations than the current informations I already have, it sends a notification or anything else. But I'm not sure if it's the best way to make it.

I also heard about the observer pattern but I'm not sure if it's applicable there since I have no control on the state changement at the API level.

Thanks for you answers, I hope I'm clear about what I'm trying to achieve, feel free to ask if you want more informations.

You will have a hard with that if you want to implement the querying within the app. I'd suggest you to build a server application that constantly queries the API and sends out a push notification (for example via Firebase Cloud Messaging) to all users that are subscribed to your server application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM