Using Android Device as Daily Function Calling API

Hi guys, it's a august month, I really want to share something worth today. I found an unique idea for my issue. This is about notification daily that's in Food Today app that I usually do it manually. Before I usually push notification about food holiday everyday. But the time when I pushed it. It's random not always exact time.

Then suddenly in my mind I think I can make it automatically pushing notification without third party like firebase function that now I have. I had it for backup data firebase in other project every week one time. Because you know it's quite expensive for me to do it daily. So I made it only once a week and so far I satisified.

And as you know in Android we can do periodic using AndroidAlarmManager you can check here And I combine it with firebase notification so at spesific time 5:00 am everyday. And so far It always call the firebase notif. If you're curious about this app you can download it on Feel free to try and rate it.

So this is a sample code that I have made. "runFoodHolidayNotif" is a function to call push notification. So it's not hard to implement in our app. And yeah it saves a little bit money to use another third party. Maybe in the future I will use it to call API at the specific time maybe and doing some check in that time. It will be useful for it.

if (Platform.isAndroid && foundation.kDebugMode) {
await AndroidAlarmManager.periodic(
const Duration(hours: 24), //Do the same every 24 hours
0, //Different ID for each alarm
wakeup: false, //the device will be woken up when the alarm fires
startAt: DateTime(,,, 5, 0), //Start whit the specific time 5:00 am
rescheduleOnReboot: true, //Work after reboot
exact: true,

And yeah the conclusion is we have another easy way and cheap way to implement daily function in spesific time without third party, we can just use our android device if you have. But on iOS I think it's impossible to do it, because I can't find a similiar way like AndroidAlarmManager.

Thanks for reading my simple post, Hope you can learn new things today. See you on the next post. Bye bye.

Popular posts from this blog

How to restart the app with flutter Android and iOS

Missing system image Android Studio solution

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android