I don't know how to check if app is installed or not on phone! Or when App is installed, open the app, otherwise open the Appstore link to download the app. I'm using swift 3. I want to do it using app name or bundle identifier. Thank You!
-
check this: http://stackoverflow.com/questions/6854362/iphone-check-if-an-app-is-installed – aircraft Jan 09 '17 at 10:01
-
how to add URLScheme in app & get result – Jan 09 '17 at 10:05
6 Answers
func openApp(appName:String) {
let appName = "instagram"
let appScheme = "\(appName)://app"
let appUrl = URL(string: appScheme)
if UIApplication.shared.canOpenURL(appUrl! as URL) {
UIApplication.shared.open(appUrl!)
} else {
print("App not installed")
}
}

- 3,942
- 4
- 31
- 54

- 1,282
- 7
- 13
-
i hard coded the app name, inside the function, just for an example. In practise you should remove this line: let appName = "instagram". Then just pass in the app name you want to open eg. facebook – torinpitchers Jan 09 '17 at 10:06
-
This code Show me this error "This app is not allowed to query for scheme APPNAME" – Jan 09 '17 at 10:26
-
6
-
How to add app scheme in info.plist, if you share screenshot it would be better. – Arshad Shaik Jun 13 '19 at 10:49
-
in iOS 15 canOpenURL method only check for scheme in info.plist. Thats all. If you added scheme, it will return true even if application you need is not installed on device. – Dmytro Yashchenko Sep 30 '21 at 17:33
-
@DmytroYashchenko I tested it for iOS 15 and it is not. If the application is installed and it is in the LSApplicationQueriesSchemes list, then the answer for canOpenURL is false – Genja Grishin Oct 26 '21 at 08:13
-
@Genja Grishin Yes, you are right. But usage of LSApplicationQueriesSchemes also creates another problem. But its problem only in some cases. For example, you develop 2 applications, "A" and "B", both of them should open google maps. You add google maps schemes to their LSApplicationQueriesSchemes. Then, both of your apps are installed on device. And now the problem - if google maps are installed of device, "A" and "B" will open maps. But, if google maps are not installed, "A" will open "B", and "B" will open "A" instead if returning false in canOpenURL... – Dmytro Yashchenko Oct 26 '21 at 09:39
-
Can u help how to check if Facebook is installed on my device ? canOpenUrl returns always true – Аба-Бакри Ибрагимов Jan 20 '22 at 16:10
After looking into so many answers, i am writing a common code which will help for new users. If you have two mobile apps as App1 and App2, if you want to check in App2 that App1 is already installed in his device or not, here is code below.
In App1 add this property in info.plist file
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>com.companyName.App1</string> <key>CFBundleURLSchemes</key> <array> <string>App1</string> </array> </dict> </array>
In App2 add this property in info.plist file
<key>LSApplicationQueriesSchemes</key> <array> <string>App1</string> </array>
In App2 write the method to check if app is installed or not on phone! Or when App is installed, open the app, otherwise open the Appstore link to download the app as below.
func checkAndOpenApp(){
let app = UIApplication.shared
let appScheme = "App1://app"
if app.canOpenURL(URL(string: appScheme)!) {
print("App is install and can be opened")
let url = URL(string:appScheme)!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
} else {
print("App in not installed. Go to AppStore")
if let url = URL(string: "https://apps.apple.com/us/app/App1/id1445847940?ls=1"),
UIApplication.shared.canOpenURL(url)
{
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
}
I hope it will help some one.

- 1,095
- 12
- 18
Between the other answers and their comments, I'm getting the impression that the asker wants to be able to see if any given app is installed.
Beginning with iOS 9.0, that is not possible.
Apps for iOS 9 and later must have a list of requested URL schemes in the Info.plist before being allowed to use canOpenURL:
. This is to protect user privacy, as advertisers were abusing this functionality in an arguably invasive fashion. (See this excellent post for more details on those changes.)
Of course, that list is static and cannot be changed after build time or submission to the App Store. If Apple doesn't like the ones you chose, they have every right to reject it.
I'm afraid that what you're asking isn't possible within reason for iOS 9.0 and later.
Edit: I also want to make clear that an app's URL scheme may not necessarily match nicely with its name. (This is more of an issue of a badly named constant than a functional issue.) There used to be a giant list of known URI schemes with documentation for each, but poignantly and fittingly enough, it seems that the wiki hosting it has shut down.

- 517
- 3
- 11
Swift 4.1. One developer can have more than one app on AppStore. So, I need to check if user has installed other apps or not by the same developer. I had Bundle ID's of other apps. Although you can use Appname instead of Bundle Id. So I followed the following steps.
In your current app add LSApplicationQueriesSchemes key of type Array in your info.plist file. Make entry of bundle id or Appname of app there which you want to open from your app.
Other app should have their bundle id or Appname entry in that app URL Scheme.
- In your current app check if that app in installed in iPhone or not and can open accordingly.
let app = UIApplication.shared let bundleID = "some.Bundle.Id://" if app.canOpenURL(URL(string: bundleID)!) { print("App is install and can be opened") let url = URL(string:bundleID)! if #available(iOS 10.0, *) { UIApplication.shared.open(url, options: [:], completionHandler: nil) } else { UIApplication.shared.openURL(url) } } else { print("App in not installed. Go to AppStore") }
- You can also test it from Safari browser. Just type the following in search bar
URL_scheme:// or Bundle_Id://
If app is installed the it will show alert with Appname to open it in app.

- 9,221
- 1
- 66
- 58
-
-
It is working with ```com.apple.mobilemail``` (not in simulator, you need a device) @MycroftCanner – Dasoga Aug 13 '21 at 15:17
This worked for me (Swift 3.0)
Below two inputs should be provided:
<APP URL SCEHME>
: The URL Scheme of the app which you want to open<YOUR APP URL>
: The App Itunes URLfunc openApp() { let appURL = NSURL(string: "<APP URL SCHEME>") if UIApplication.shared.canOpenURL(appURL as! URL) { print("Opening App...") }else { UIApplication.shared.openURL(NSURL(string: "<YOUR APP URL>")! as URL) } }

- 3,261
- 1
- 25
- 33
-
-
@SanpreetSingh You cant, the dev of that app will need to provide the URL scheme, else you cant check, it's for security reason – Tj3n Jan 09 '17 at 10:29
-
URL scheme is not add in my previous project so can i get the status of app is installed or not with bundle identifier or app name – Jan 09 '17 at 10:33
-
You've to add the URL Scheme and update your app. For more details see: http://stackoverflow.com/questions/8201724/how-to-register-a-custom-app-opening-url-scheme-with-xcode-4 – Imad Ali Jan 09 '17 at 12:34
first go to info.plist, add LSApplicationQueriesSchemes add an item and place instagram on that item. Now this code will run perfectly.
let appName = "instagram"
let appScheme = "\(appName)://"
let appUrl = URL(string: appScheme)
if UIApplication.shared.canOpenURL(appUrl! as URL)
{
UIApplication.shared.open(appUrl!)
} else {
print("App not installed")
}

- 121
- 7