I want the user to automatically be taken back to the app he came from when he finishes interacting with my app. Is it possible?
Asked
Active
Viewed 3,037 times
2
-
1how did the user get to your app? – luk2302 Dec 25 '15 at 12:21
-
from safari for example (universal links) – doodledood Dec 25 '15 at 12:22
-
please read this [Bring previous app back to the front when user is done with my iOS app](http://stackoverflow.com/questions/13447101/bring-previous-app-back-to-the-front-when-user-is-done-with-my-ios-app) – Jaydeep Patel Dec 25 '15 at 12:57
-
Thanks the link, this makes me sad :( – doodledood Dec 25 '15 at 13:00
1 Answers
2
I think this may be possible.. if the user opened your app from inside another app then he would have obviously opened your application via URL scheme. The source application will have the bundle identifier of the app from which it was opened from safari. So you can open safari from your application using url scheme. The only limitation is that you can only open a limited number of applications and not everyone which is available on the users phone as you won't have access to the entire URL schemes list.
Here is a list of common url schemes.
http://aijazansari.com/urlschemelist/#Phone
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
[IXIGATrackerUtil trackCampaign:url];

Ankit Srivastava
- 12,347
- 11
- 63
- 115
-
Hey, it seems impossible to get the source url: https://stackoverflow.com/questions/29175607/how-to-get-source-url-from-bool-application-openurl – doodledood Dec 25 '15 at 15:34
-
You are right, all I am saying is that you can open a set of specific apps based on their bundle identifier. You can create a dictionary and map each identifier to the url scheme. But all this may not be worth your effort as this will only solve very limited cases. You can check this out for more info. http://stackoverflow.com/questions/419119/launch-an-app-from-within-another-iphone – Ankit Srivastava Dec 25 '15 at 16:30
-
Well I don't think it can help me solve my problem but thanks for the answer – doodledood Dec 25 '15 at 16:58
-
1How 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 22 '17 at 20:03
-
Ahmet Akkök - I've seen that on an iOS Keyboard Extension as well and I am wondering how they are doing it :( Any idea how? – Mihai Fratu Nov 14 '18 at 12:52
-
The keyboard probably has an idea of what app it's in and stashes that prior to opening the companion app. – saagarjha May 01 '20 at 23:38