Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically check whether an app is installed

I would like to know whether there is a Swift equivalent of the following Objective-C code

NSURL *appURL = [NSURL URLWithString: @"myapp://"];
if ([app canOpenURL: appURL] {
 NSLog(@"The app is this URL Scheme is installed on the device");
}
like image 394
Romain Avatar asked Oct 22 '14 14:10

Romain


People also ask

How do I know if an app is installed or not?

isPackageInstalled("com. example. this. app", pm); // This will return false on Android 11 even if the app is installed: isPackageInstalled("another.

How do you check app is installed or not in Android programmatically Kotlin?

Call the method isPackageInstalled() : boolean isAppInstalled = isPackageInstalled("com. android. app" , this.

How do I track installed apps on Android?

The easiest way of finding out all the installed apps on your phone is through your device settings. There are three main steps to accessing this list. Go to Settings and find the App Management or Apps section, depending on your phone. If you can't locate it, simply perform a quick search within Settings.

How do I know if an app is installed or not in Swift?

Finally, call navigator. getInstalledRelatedApps() to check if your Android app is installed.


1 Answers

Before reading this answer you must solemnly swear not to do any of the activities on the page you linked to. (Looking for dating apps? Seriously?)

The method is essentially the same:

if let appURL = NSURL(string: "myapp://test/url/") {
    let canOpen = UIApplication.sharedApplication().canOpenURL(appURL)
    println("Can open \"\(appURL)\": \(canOpen)")
}
like image 119
Nate Cook Avatar answered Sep 24 '22 16:09

Nate Cook