bhargav Vagadiya
bhargav Vagadiya

Reputation: 48

Run Flutter MethodChannel even if app is closed

I want to run flutter method channel every 5 seconds even if app is closed so what I should do?

Upvotes: 0

Views: 1491

Answers (1)

Gebes
Gebes

Reputation: 347

Depending on the operating system, you can create a background service that periodically calls your MethodChannel. Check this out for Android.

Also, this use case has a straightforward plugin.

Note: on iOS, you can't just call a task always in the background. The App will be suspended 40 seconds after the user goes out of it. There are specific scenarios, e. g. Push notifications where your App will become active, but these are "one time" events and not something you can do every 5 seconds. And if the user completely closes your App, your 5 second scheduler will be killed, no matter what.

Upvotes: 1

Related Questions