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");
}
isPackageInstalled("com. example. this. app", pm); // This will return false on Android 11 even if the app is installed: isPackageInstalled("another.
Call the method isPackageInstalled() : boolean isAppInstalled = isPackageInstalled("com. android. app" , this.
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.
Finally, call navigator. getInstalledRelatedApps() to check if your Android app is installed.
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)")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With