1

I am building an app for a client that requires the ability for users to set an alarm time in the app, then be able to run the app in the background, then when the alarm time is hit display a notification.

I know Apple has some limitations on how long apps can run in the background, so what is the proper method for going about this?

I already know how to use local notifications, so showing a notification when the alarm is actually hit is not an issue. I just want to make sure I am able to enable the app to 'wake up' when the alarm time is hit and call the code for showing the local notification.

JimmyJammed
  • 9,598
  • 19
  • 79
  • 146
  • Possible duplicate of [How to do Clock ringing with app in background](https://stackoverflow.com/questions/8995908/how-to-do-clock-ringing-with-app-in-background) – picciano Apr 11 '18 at 19:49

1 Answers1

0

I don't believe that your app can wake itself up upon a notification, users wake your app up by interacting with the said notification.

However, you can keep your app running in the background by various methods so you don't have to worry about waking it up. One of these methods is to let the app pretend to be a music player and constantly play some sound clips(just make them silent to not disrupt the users), this way the OS won't terminate your app and will allow it to run in the background.

Doing so of course against Apple's guideline, is highly likely that your app will be rejected from the App Store unless you have very good reasons to convince the reviewers.

My company is right now developing an app that uses similar approach to keep on running, since its an in-house application we don't need Apple to review it.

Craig Zheng
  • 443
  • 1
  • 5
  • 17
  • how long the app will remain in background if we play the music. – iLearner Apr 10 '14 at 05:27
  • as long as you don't stop playing, it will keep going. You can loop the music to make it infinity. – Craig Zheng Apr 10 '14 at 05:50
  • ok thanks for the response, does the apple approve such apps. – iLearner Apr 11 '14 at 04:22
  • No. apple will highly likely reject apps with inappropriate background activity. – Craig Zheng Apr 11 '14 at 04:49
  • oops, so is there any better way to keep the app running in background for long time (maximum possible time) so that it should not get rejected by apple. – iLearner Apr 11 '14 at 06:19
  • Other than the extra 10 minutes that you can request for your app, no, see this SO post http://stackoverflow.com/questions/9738488/run-app-for-more-than-10-minutes-in-background It lists all the app that is allowed to run in the background, if your app isn't on the list, your app won't be allowed to run in the background, at least Apple won't approve your app to be sale on App Store. – Craig Zheng Apr 11 '14 at 06:32