3

My iOS 4/5/6 app is meant to be used briefly. I want the user to click a "Done, now go away" button which takes them back to the app they were using before mine came to the front.

Is there a way for my iOS to put itself in the background while returning the previous app to the front?

On an iPad, the user can get that effect by doing a four-finger swipe horizontally across the screen. But that gesture is not a complete solution because (a) that gesture does not work on a handheld device, and (2) not many users know of that gesture. I want to programmatically return the previous app to the front.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154

2 Answers2

6

I want the user to click a "Done, now go away" button

That button is the Home button.

I want to programmatically return the previous app to the front.

There's no public API for switching to another app. Users have a number of options for switching between apps, though. In addition to the swipe gesture you mentioned, they can do a four-finger upward swipe to get to the list of recent apps, or double-tap the home button for the same effect, or hit the home button once to go back to Springboard. Users, not apps, are supposed to be in control of which app is in the foreground. And the way they do that should be standard from one app to another. I can understand wanting to make life easier for the user, but what you're trying to do just isn't possible with the available API.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • 1
    How does Google GBoard iOS keyboard do it then? When microphone is clicked it swithes to it's own Speech-to-text app and as soon as you finished dictation it comes back to the previous app just like back-to-app button. – Ahmet Akkök Apr 17 '17 at 08:32
  • @AhmetAkkök Bear in mind that this question is now 4.5 years old and iOS has changed rather a lot in the interim. I'll update the answer if I have time, but I don't at this very moment. – Caleb Apr 17 '17 at 14:51
  • 2
    That is what I'm saying. Google did it. Please go ahead and install GBoard and have a long click on the space key. It does go to it's host app and come back by itself. Would there be an exception for host & extension couple? My other guess is that Google somehow hacked back-to-app func which is available since iOS9. Anyways I'm looking forward to seeing your update – Ahmet Akkök Apr 21 '17 at 10:57
  • @Starwave here you are: https://stackoverflow.com/questions/42516357/how-does-googles-custom-ios-keyboard-gboard-programmatically-dismiss-the-fron – ndreisg Aug 28 '19 at 09:59
  • Thanks, yes, that is exactly what I ended up implementing in the end. – Starwave Aug 28 '19 at 12:49
2

I Don't think you can do that if the previous application is not your property or if you are not aware if a URL Scheme has been incorporated in the previous application that you know of.

Launch App Via URL Scheme!

Abhishek Singh
  • 6,068
  • 1
  • 23
  • 25