How to run timer even app in background or foreground in flutter? - flutter

i want to hide button for specific time when user tapped on button, and the button show when time is completed, even app in foreground or background

the ultimate solution is to use foreground services, and with android, it comes with a sticky notification to prevent the system from killing the app.

Related

How to detect if Flutter webview is in foreground or background?

I have a requirement where I need to record the time user spends viewing a certain attachment. I am opening the item in an external webview provided by flutter_inappwebview package on pub.dev.
Now to detect the amount of time user is spending I run timers. I want these timers to stop when the app is not in foreground, so I used Flutter's lifecycle events to detect this. The problem is, as soon as the webview is opened, the lifecycle event paused is called. Now i don't know if the user is viewing the item or has pushed the app to background.
Any leads will be helpful thanks.
I tried using flutter's lifecycle events, but they fire as soon as webview is launched and does not fire any other events after the webview is opened until user comes back to the app.

Notification Timer should continue even if app is close without another notification

In my app there is condition where a notification is generated at button click and showing with Countdown it is working fine if app is open. With the help of background service notification timer also working fine even if app is close but I have to show extra notification for Background service in Android devices.
I am using flutter_local_notifications: ^9.2.0 and flutter_background_service: ^2.3.9
Is there any way to achieve my goal without background service and without extra notification.

Trigger an action when timer expires in the background

I’ve developed a Xcode app to trigger an action on timer expiry. This works fine when the app is visible on the device. However when the app is minimised eg. the Home button is pressed, the app doesn’t work. It seems like the app gets suspended. It resumes the countdown when it is brought to the foreground again.
Any guidance will be appreciated.
Timers will only run in the background if your app is running in the background for another reason. You will need to enable a background mode on the capabilities page. Your timer will also need to have already started when you enter the background
This may also be helpful:
https://www.raywenderlich.com/5817-background-modes-tutorial-getting-started

How to wake an app when screensaver is displayed

I have an application that gets hidden (but is still running in the background) when the screen saver starts on the 4th Generation Apple TV.
How can I bring the app to the foreground (hide screen saver) when an event (update to an endpoint which I am long polling) happens in my app which is running in the background?
I don't think there's any way to do this. When the screen saver is running, your app can still be the foreground app, but it will be in an inactive state. This is similar to what happens on iOS when the user locks the screen while using an app. Like the iOS lock screen, the user might be actively using the system when it's in this state. For example, you can use Siri without dismissing the screen saver.

How can I fix a display flash during a transition from background to foreground for my iPhone app

For an iPhone app I am working on, I reset the state if the app has been in the background too long. This is a lengthy process (1-2 seconds) so I display a progress indicator during the reset. Unfortunately, this causes the display to flash as the app transitions from the background to the foreground. The flash is caused by the switch from the default image that iOS snaps and the progress indicator that I display. I know I can display the progress indicator as the app initially enters the background state and eliminate the flash. However, I don't want to do this if the app wakes up after a short period of time. I want it to use the default image the iOS snaps. I'm a little stuck on how to overcome this. Does anyone have any suggestions?
Thanks.
pmb