Trigger an action when timer expires in the background - swift

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

Related

How to run timer even app in background or foreground in 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.

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.

Is it possible to pause my flash app on iphone by pressing home button?

I'm quite new to Flash. So here's my problem: I've created my app and it works great. But when I press home button on my iphone, my app minimizes and when I open it from multitasking apps, it simply restarts. Is it possible to freeze or pause the game instead of stop? Thanks!
By default the application should be eligible for the 'freeze-drying' iOS4+ functionality that resumes an app from the last place it left off. That may require a setting to be adjusted in your app descriptor (UIApplicationExitsOnSuspend should be false).
If you simply need to save data when the application is quitting, you can listen for Event.EXITING on the NativeApplication:
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExit);

iphone lock button and the running app

this may be a simple one, but I don't know the answer.....
For testing whether my location-based app receives updates in background, I usually run the app and then press the Home button to put the app in background. However, I am curious whether pressing the Lock button (at the top) will put the app in background or not.
Regards.
Yes. Hitting the lock button does background the application. However when you unlock it, the application is then brought back to the foreground. Should be able to test this within your App Delegate and simple log statements.

IPhone: Why does my app resume and not restart when I relaunch it on device?

I don't know if this is an iOS4 thing or something, but basically say I have a few screens in my app. Now, when I hit the home button and relaunch my app it launches the app on the screen where I left off. It's almost like it's not restarting my app, but resumes it. I don't want it to do that. (I'd like it to show my splash screen main menu, etc. )
Does anyone know how to resolve this? thanks
In iOS 4, apps are suspended (not terminated) when the home button is pressed. When you "relaunch" the app, it is simply moved to the foreground. If you want your app to terminate when the user presses the home button, set the value of UIApplicationExitsOnSuspend to YES in your app's Info.plist file. If you do this, when the user taps the home button the applicationWillTerminate: method of your app delegate will be called and then your application will terminate.
I think this should help you. Basically what you need to do is disable the multi-tasking features of iOS4.
http://www.iphonedevsdk.com/forum/iphone-sdk-development/60989-disable-multi-tasking-ios4-application.html
That's exactly the multi-tasking you asked about yesterday working behind the scenes. You need to opt-out if you want that behavior. See answers to your previous question here. Have you read the answers there???