Skip to main content
Inspiring
April 8, 2015
Answered

Execute in background for more than 3 minutes?

  • April 8, 2015
  • 2 replies
  • 3114 views

Hi,

My app is a timer-app. It works fine for 3 minutes in the background. If I set it to 5 minutes, it only works (in the background) for 3 minutes, then it stops. (it continues when I open the app again).

I believe there was a 10 minute "window" before, but now it's only 3? Is it possible to use beginBackgroundTaskWithExpirationHandler or something like that to ask for more time?

This topic has been closed for replies.
Correct answer kheftel

Apple only allows long-running background events for certain types of apps, e.g. background audio apps, like you noticed.

This type of situation would be better served with a local notification.    

2 replies

kheftel
kheftelCorrect answer
Inspiring
April 10, 2015

Apple only allows long-running background events for certain types of apps, e.g. background audio apps, like you noticed.

This type of situation would be better served with a local notification.    

gronli21Author
Inspiring
April 10, 2015

Thanks for the reply. I do have local notifications also, but let's say the timer is set for 5 minutes and the user open the app at 4 minutes (to check it's time), then it will continue from 3 minutes (although the local notifications will kick in at the right time).

I will let Apple remove my 5 minute timer, and I've already submitted an update for my 3 minute timer, which works.

kheftel
Inspiring
April 10, 2015

That's a good point.  Is there a way to check, when the app resumes focus and has 1 minute left, when the local notification is set to go off, and adjust the time to match?

So a user starts a timer with 5 min, and goes away and comes back 4 min later.  The app looks at the local notification that's scheduled, sees there's only 1 minute left and adjusts its display accordingly.

I had always assumed that's how the timers worked in timer-based free-to-play games and in the native clock app, but I don't know for sure since I've never tried to code it for myself.    

Inspiring
April 9, 2015

I only tested in AIR 16 (16,0,0,252), but there it's definitely possible for a background worker to run for 5 minutes, at least on desktop. Are you testing on Android?

gronli21Author
Inspiring
April 9, 2015

Forgot to write that it's on iOS. I've tried Air 16 to the latest 17 (release and beta). On my first version it did work for 5 minutes, but then I used "backgroundmode audio". But Apple said I had to remove it for my update, cause I couldn't play audio to keep a timer alive (I played a silent soundfile, and then an alarm sound when the timer was done. This worked fine, even if the app was in the background).

User Unknow
Legend
April 9, 2015

Adobe AIR * iOS Settings

Check section

Supporting background tasks on iOS