1

I want to check user's posts every few minutes to see if anyone has replied and update a Text widget to show the number of new messages. This would be just like the way Facebook lets you know whenever there is any new activity. I'm using a mysql database as my backend. Was thinking to simply make a mysql query every few minutes. Does anybody know how Facebook does it? Would it be better if I moved over to something like NodeJS instead of making expensive MYSQL database queries?

Meggy
  • 1,491
  • 3
  • 28
  • 63

1 Answers1

1

You can use this package: https://pub.dev/packages/background_fetch

or

If you need something more reliable, implement natively for each platform, and use MethodChannel to integrate with Flutter.

For Android: https://developer.android.com/topic/libraries/architecture/workmanager

For iOS: https://developer.apple.com/documentation/backgroundtasks/bgtaskscheduler

As for How Facebook does it, check this: How does facebook, gmail send the real time notification?

Akshar Patel
  • 8,998
  • 6
  • 35
  • 50