Is it possible to launch any app from within another app?
For example, in my application, I want the user to push a button and launch another app (don't close the current app, just open another app and switch to it).
How can I do it in iOS 8 using Swift?
Others have described the right idea already here but with some issues around handling the URL and the function to call.
UIApplication.shared.open(_ url:)
is deprecated, and replaced with a new version with a completion handler.As others have mentioned, you need the recipient app to have defined a URL scheme. Provided they have, you can do something like this:
No matter what language you are using (Obj-C/Swift), you can always use
openURL
to open a URL scheme to launch a app (if the URL is provided).We can do this by creating custom URL of that app and after that we can open custom URL on click event of a button.
The only way to do this is to use a deep link, which the developer of an app must have created.
The iOS SDK does not allow your app to interact with other apps unless it uses the new Extensions framework introduced with iOS 8. However, this extension only allows you to provide content and capabilities of your own app within another: you cannot force another app to open.
What you've described is only possible with deep links that are fairly uncommon and must be defined by the developer of the app you are trying to open.
So, for example, a link in your app could open the Pocket application, which allows you to save articles for later reading, with a
pocket://
link (as opposed tohttp://
orhttps://
) and, similarly, the Pebble Smartwatch application can be opened with apebble://
link. However, these are links that are defined by the developers of those applications and this technique does not apply to all apps.I think you are looking for Apple URL Schemes. If the third-party app have any URL Schemes defined, then you can use the following code to open it: