Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run background process in flutter,when app closed to show Notification and Hit API,

I 've tried background_fetch: '^0.1.0'

and alarm_manager package, but when the app is closed, it removed from the recent apps, and it does not work. I need to hit API every 15 min n show Notification if data is there

when App is closed any solution without writing Native code. I don't know iOS development, I know Android I don't need Firebase Push Notification

like image 902
theshivamlko Avatar asked Feb 25 '19 18:02

theshivamlko


People also ask

How do I make my apps run in the background on Flutter?

A plugin to keep flutter apps running in the background. Currently only works with Android. It achieves this functionality by running an Android foreground service in combination with a partial wake lock and disabling battery optimizations in order to keep the flutter isolate running.

How do you respond when an app is in the background in Flutter?

It offers a bunch of features like for example scheduling when notifications should appear, periodically show a notification (interval-based), handle when a user has tapped on a notification when the app is in the foreground, background, or terminated, specify a custom notification sound and much more.


Video Answer


1 Answers

Background fetch is not controllable on iOS by the app developer. It is controlled by the OS. You sign up for "Background App refresh".

Once your app has registered for Background App refresh. The OS will awaken your app periodically at it's discretion to let you do some work. Then your app is put right back into sleep again. Depending on how long it's been scene the user opened your app it may have been purged from ram. If you are purged from ram it's very likely you won't be awakened again until the user opens your app or is plugged into power and charging the phone.

From https://pub.dev/packages/background_fetch

iOS can take some hours or even days to start a consistently scheduling background-fetch events since iOS schedules fetch events based upon the user's patterns of activity.

iOS favors Push notifications to save battery life. All push notifications run though apples APN service. enter image description here

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server This saves on battery life as only one constant connection has to remain open on the device to Apple. Instead of multiple connections from many servers.

like image 150
Kent Avatar answered Sep 19 '22 08:09

Kent