Home > Software engineering >  Most effective way to manage push notifications in Flutter for IOS and Android?
Most effective way to manage push notifications in Flutter for IOS and Android?

Time:08-01

I am working on an app that (ethically) scrapes for products in shortage and lists what products are available at any given time, notifying the user when new stock is available. The original plan was to have a background process run to refresh the product list and detect any changes, every minute or so. However, I then learned that Android and IOS tend to limit how often a background service can run. Ideally I would like to do this without a server, so my questions are as follows:

  1. Is there anyway to implement the above with just background processes on both IOS and Android via Flutter/Dart?

    • (IE, Is it possible to create a persistent or frequent(1x/min) background processes that can scrape and notify the user in Flutter/Dart that works on IOS & Android?)
  2. If not, is the only way to accomplish something like this to have a server scrape the site, detect change, and then have the server push that to the clients via FCM?

To anyone who reads this thank you very much for your time, I'm looking forward to what you have to say. Kind regards.

CodePudding user response:

For flutter I don't know to be completely honest with you. However , you can try using a python web scrapper if you can and post your python script on an AWS lambda function. This lambda function can then have Triggers. These triggers can be whatever you want (ex: every hour , every minute , once someone accesses your website). There is a certain quota for you to use Lambda Expressions though however. Be very wary when using aws as they do not notify you how much money you've spent , and there are no billing limits implemented in the aws console. You can then connect your python script to send an FCM using firebase notifications.

CodePudding user response:

There are many solutions for that, You can use firestore, a firebase database that can render the changes automatically in real-time without writing manual codebase for that in the APP, It integrates with flutter out of box. For more info you can check. This database provides you onCreate/OnUpdate/onDelete/onWrite Triggers that you can use to put your business logic like sending push/sms/email etc. https://firebase.google.com/docs/firestore

Or you can use other pub/sub based solution using flutter web_socket_channel https://docs.flutter.dev/cookbook/networking/web-sockets

For this you will have to implement streams (pub/sub) using Kafka or some other tools.

  • Related