Open another app from your iOS app.

Divesh Singh
1 min readOct 25, 2022

--

From one iOS app, we can open another app by using the below steps

Suppose there are two apps, one mother app, and a child app.

suppose the child app has a scheme name: “com.iosapp.childApp”

and the mother app has a scheme name: “com.iosapp.motherApp”

Child app Setting

so the child app needs to add the mother app scheme name in the app like below under the info.plist with key LSApplicationQueriesSchemes

once it is done.

Mother App Setting

now we have to write the code on the action in the mother app from where you want to open the child app.

code is below: schemeName must be child scheme Name

func redirectToApp(schemeName: String, appLink: String?) {if let url = URL(string: "\(schemeName)://"), UIApplication.shared.canOpenURL(url) {UIApplication.shared.open(url, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)} else if let urlString = String.emptyCheck(string: appLink), let url = URL(string: urlString) {if #available(iOS 10.0, *) {if UIApplication.shared.canOpenURL(url) {UIApplication.shared.open(URL(string: urlString)!, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)}} else {UIApplication.shared.openURL(URL(string: urlString)!)}
} else {
print("Not able to open it")}
}

--

--

Divesh Singh
Divesh Singh

Written by Divesh Singh

Postgraduate from JEC Jabalpur || iOS and macOS developer, traveler |||| EM at Darwinbox | Ex-Samsung || Ex - Optimize IT Sys | Ex - R Systems

No responses yet