4

I know that audio players and Voip apps can run in background on iOS.

Is there a way to show UI from background (except LocalNotifications)? I mean full screen UI.

A method which uses private API or other tricks are acceptable. The application will be signed with enterprise certificate and won't be deployed/reviewed by AppStore.

A method which works only on jailbroken iOS device isn't acceptable.

Victor Ronin
  • 22,758
  • 18
  • 92
  • 184
  • 1
    If you are showing a full screen UI, then it isn't in the background.... – lnafziger Aug 01 '12 at 16:22
  • That's my main point. I want to be able to switch from background to foreground. – Victor Ronin Aug 01 '12 at 20:03
  • What's wrong with Local Notifications? Local Notifications and Push Notifications are specifically meant for this case. You have an app in the background, something happens that might make the user want to bring the app to the foreground, so you show a notification. Then they click the button and the app is brought to the foreground. Please explain how what you want is different - there must be something I'm not understanding. – ajh158 Aug 07 '12 at 14:49
  • 2ajh158: Local and Remote notification let user know that something has happened. However, it's user choice whether he want to launch some app or not. The user can just ignore the notification and continue doing what he/she was doing. I need a solution where the user will be required/forced to interact with UI. – Victor Ronin Aug 07 '12 at 18:49
  • There's no way to solve that problem. If the device isn't locked down with guided access settings, user is supposed to execute control over launching of apps. There may be some private API hacks but they're very likely to break between versions. – ilya n. Sep 27 '13 at 11:13
  • @ilyan. I explicitly said that "private API or other tricks are acceptable". I aware that may and will break at some point in future. – Victor Ronin Sep 27 '13 at 14:49
  • @VictorRonin by the time did you find a way to solve this issue? – JBA May 20 '16 at 09:36
  • @JBA Back then (it was 4 years ago) I haven't found a way to do. I became quite good at finding private API's. However, everything what allowed an app to switch to foreground was protected by entitlements. The only solution which I found was locking down a device to one app through MDM (this brought this app to the foreground). However, the solution wasn't reliable enough – Victor Ronin May 20 '16 at 16:15

2 Answers2

0

Check out this document and search for "Implementing Long-Running Background Tasks" Basically you need to register your app to run in the background instead of being suspended and listen for notifications.

from the docs: " An app declares support for a service using its Info.plist file. Add the UIBackgroundModes key to your Info.plist file" and ".....values lets the system know that your app should be woken up at appropriate times to respond to relevant events."

http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW20

Beleg
  • 362
  • 2
  • 23
  • Thanks. I read this document. It has information on how to run in the background. However "woken up at appropriate times" only means that system just let an application know about some events. The question is how to show UI in response to these events. – Victor Ronin Aug 01 '12 at 20:02
  • what happens if, when you have a listener on one of these events, you do something like pop up an alert box? – Beleg Aug 06 '12 at 14:17
  • Nothing happens. It doesn't show the alert. The same is true, if I try to launch some application using URL. As I understand Springboard manages which application is displayed. The rest of applications work with offscreen buffers. So, no UI is visible to a user. – Victor Ronin Aug 06 '12 at 18:12
  • From what I am reading, it looks like that you register with the OS so that when XYZ happens, it wakes your application up. Your code can not force the app to wake from the background, it can only respond to the applicationDidBecomeActive: event once the OS decides to wake your app back up. I am not sure of the details for telling the OS that you want to be woken up when XYZ happens. I gathered most of this from reading this page: http://www.codeproject.com/Articles/124159/Hour-21-Building-Background-Aware-Applications how it helps. – Beleg Aug 06 '12 at 18:49
  • hope it helps, not "how it helps" – Beleg Aug 06 '12 at 18:56
  • Thanks. That's the problem. My application already can run in the background (this article explains how to make your app run in the background). However, my application can't force system to move my app to the foreground. Only if users clicks on my application icon, click on my local notification than my application becomes foreground app – Victor Ronin Aug 07 '12 at 18:19
  • Page Not Found! – Vineesh TP Feb 10 '17 at 12:09
0

Victor, have you tried some trick like defining a custom URL for your App?

Springboard can start applications when parsing custom URLs; if they are in background they become foreground.

You must create a URL type into your app's info.plist in the key CFBundleURLTypes, for example "mySpecialURLType". Your application delegate also have to implement handleOpenURL: and openURL:sourceApplication:annotation:.

If you (in your background task) ask for a URL like "mySpecialURLType://", theoretically SpringBoard will start your application.

I don't know if it works, but is worth a try...

Best!

  • Thanks. Good idea :) However, I tried it before and what I found that if application is in foreground then it can do it (newly launched application will become foreground). If application is background - nothing happens. – Victor Ronin Aug 08 '12 at 02:54
  • Hmmm. I was afraid of that... as long as I know it seems impossible to do under iOS 5. Did you post it at Apple Developer forum? I will keep thinking... – Bruno Basseto Aug 08 '12 at 13:09
  • 1
    I will try to post it there. However, based on my previous experience developers there aren't very fond of such (private API) questions. – Victor Ronin Aug 08 '12 at 17:19