I want to make a constant http request in dart language even if my flutter app is closed , is there a way?

Viewed 84

What I am trying to do is , I am making an app for apartment where if someone comes at the gate , security guard enters the detail of the visitor and who the visitor wants to meet, an alert will go to the person so that he can grant or reject access, if the person whom visitor wants to meet grants access the security guard will let visitor in , in my app I want to make a background service which will constantly make a http request so that even if the owner of the flat is not at home he can grant or reject the access to the visitor over the internet ,

there is lot more in app which is dependent on background service , any help is appreciated

1 Answers

Having your app notified of an event, even if it is not currently running, is a standard feature. It is called a "Push Notification".

You can implement it using Firebase for example, but if you are looking at a smaller market segment like iOS only, you could probably use their service exclusively. Microsoft has a cloud feature called a "Notification Hub" that can simplify having multiple providers like one for iOS and one for Android.

So to sum it up: do not poll your backend. Let your backend actively notify your app using a "Push Notification". This works whether the app is running or not, you have probably seen it a million times if you own a smartphone.

You can find all the different ways to do this, flutter packages for them and tutorials and articles when you enter "flutter push notification" in your favorite search engine.

Related