Is there a way to force a background app to switch to foreground

Discussion in 'iOS Programming' started by H2G2, Oct 27, 2010.

  1. H2G2 macrumors newbie

    Joined:
    May 26, 2009
    #1
    Hi,

    my question is quite simple, but I am not sure the matching answer is that simple. Basicely, I would like my "backgrounded" * application to go back to foreground as soon as some processing (whose duration I can't forecast) is over.
    Is there a way some of you know to do such (programmatically)?


    Thanks in advance.


    * About "backgrounded", It could be the official way (with the IOS4 multitasking feature) or with the "Backgrounder" tool (or equivalent) on a jailbreaked iPhone.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Using the official APIs certainly not. The user is in control, not you. I have no idea about Jailbroken devices or the "Backgrounder" tool. Perhaps they provide documentation you could consult?
     
  3. H2G2 thread starter macrumors newbie

    Joined:
    May 26, 2009
    #3
    Thanks for your answers Robbie.

    I had little hope about another answer.

    Code source is provided here. But I can't use backgrounder yet*, thus it's quite difficult to "retro-engineer" it without knowledge of its behavior.

    * (actually I don't plan jailbreaking my iPhone unless I am sure this will allow me to do this).
     
  4. Luke Redpath macrumors 6502a

    Joined:
    Nov 9, 2007
    Location:
    Colchester, UK
    #4
    The accepted way of doing this is to send a local notification when the background task has completed - this will display an alert to the user and they can decide whether or not to return to the app (the alert will have a button to do this).
     
  5. H2G2 thread starter macrumors newbie

    Joined:
    May 26, 2009
    #5
    I read about this possibility, but unfortunately, I really want the application to switch on itself.

    Thanks anyway for you answer Luke.
     
  6. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #6
    It's worth thinking about the user-experience of such behaviour: does your App really need to come to foreground whilst the user is potentially in the middle of typing (email, SMS, etc.), playing (game, music), talking (phone, VoIP, FaceTime, etc.) and so on...?

    +1
     
  7. H2G2 thread starter macrumors newbie

    Joined:
    May 26, 2009
    #7
    In most apps : the answer is indeed "no".
    In my case, the answer is "yes". Although I can't fully develop the idea, let's just say that is the normal behavior.
     
  8. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    Location:
    Sailing beyond the sunset
    #8
    If that's really the normal behavior, then it will almost certainly be rejected from the App Store. So taking your original question in the larger context, what you are asking to do is still not possible for an App-Store app.

    If it's such a good idea, you should accept that the answer is "No" and move on to the question of whether to use a local notification or to not develop the idea further at all. If, at some point in the future, the ability to programmatically pull an app into the foreground becomes available, you can then add it to your existing app.
     
  9. Luke Redpath macrumors 6502a

    Joined:
    Nov 9, 2007
    Location:
    Colchester, UK
    #9
    You need to think about why you think this is necessary. Only one app on an iPhone brings itself to the foreground automatically, and that is the phone app. Nothing else does, not even VOIP apps (they use a notification).
     
  10. H2G2 thread starter macrumors newbie

    Joined:
    May 26, 2009
    #10
    I understand your concerns, and agree with the basics.
    But in my case the puprose is not to design an app store app. This is for private purpose, about which I want to deal with my foreground app and send it to background, or the opposite.
    There's no way in my design that I should encounter problems such as interfering with third party apps.
     

Share This Page