简体   繁体   中英

Can I schedule/ limit API calls in my Flutter app

I'm currently working on a personal project that allow me to view the days news at a quick glance, I use the package NewsApi and everything is going great for now, except that I use a free account and am therefore limited to 100 requests per day, I'm curious as to if I can limit my API calls by only making one a day, and not making another call till I open the app again.

PS: I've had a look at the package Cron but it seems it'll make the calls even if i don't open the app

When you first start the app, request the news and then store them maybe in a file or using shared preferences.

Also store the DateTime when you last fetched the news.

Then only fetch the new news when DateTime.now() is the next day relative to the stored time.

Then update the stored news and time with the new one.

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