I'm new to IOS developing and I've been looking for a way to get list of apps names installed on a device but from what I have found is that Apple removed this from Swift 4. Is it true and if so is there an alternative way to get them?
There is no way to get list of installed apps on IOS device , but if you have the url Scheme you can check with UIApplication.shared.canOpenURL method whether an app is installed or not
This was never a feature on iOS because it would seriously hurt a user's privacy if it was. The solution using canOpenUrl works is you know the url scheme for a certain app but in theory any app can subscribe to any scheme so there are no guarantees there either.
Related
I have several apps and I want to know from app A whether app B or C are installed. In Android I can check does package exist, but is there something like this in iOS and windows store app? I'm using Xamarin for iOS.
For iOS you can get your apps to confirm unique URL schemes and check whether they can be opened.
References:
URL schemes - https://www.appcoda.com/working-url-schemes-ios/
Can open url - https://developer.xamarin.com/api/member/UIKit.UIApplication.CanOpenUrl/p/Foundation.NSUrl/
You can use system Keychain to achieve this.
Values in system Keychain can be shared between collection of apps and you can set values like isAppBExists and isAppCExists to true/false in this apps. And then check this values in app A
Link to documentation
For UWP app, you can use PackageManager.FindPackagesForUser Method to find all packages installed for the specified user.
See the following similar topic:
how to get list of all installed apps and run them in UWP WinRT 8.1
Get List of installed windows apps
Is there any way to get all the list of installed application and check a specific bundle/app can be open which is already installed in swift ?
You can only open an app if you know its URL Scheme just like facebook provides for example. fb://
There is no way to get the list of applications. Can't say anything about jail broken devices.
How am I going to get a returned value that allows me to know whether my app was installed in IOS. In android, we can use "android.app.icon://my.package.name" by placing it in a display.newImage if it is not a nil value then I know one of my app was installed. We can't use that in an IOS device. I searched a link about using a url scheme
http://coronalabs.com/blog/2011/12/22/using-app-url-schemes-in-ios/
But the information was not that clear enough for me to understand and was not detailed at all. Is there another way to do it? I want to know the code. Thanks
The system.openURL() will return false if it can't open your app using a URL Scheme.
Does iOS offer a way for an app to query the device for information about what other apps are installed/running?
All ios apps are sandboxed so this wouldn't be possible on a non-jailbroken device
There are a few options.
First, you can lookup for the specific process name of the app, but this may be prone to error as unrelated apps may be running using the same process name, for example, I've seen both the Batman and Dark Meadow game share a similar process name: UDKGame.
Secondly, using the URL scheme. This method is useful if you know what apps you are looking for and you know that this particular app implements the URL scheme. You can do a simple canOpenURL and find out if that app is installed.
I use the second method a lot to collect the URL schemes for use in my app, AppSwitch.
If 2 other app register same url scheme, how iOS handle this?
The iOS Documentation reads:
Note: If more than one third-party app registers to handle the same URL scheme, there is currently no process for determining which app will be given that scheme.
The OSs behaviour is undefined if there are two apps registered for an URL scheme, therefore you should try to define a handler that is specific for your app to avoid this situation (e.g. awesomeMapsApp:// instead of maps://).
Actually it can be really problematic. For example, til' March 2016, an app called Grabb handles PayPal schemes so that if your app tries to open PayPal (with all the security nonce etc. within the call) it launches Grabb instead, and you can do nothing about it. Even with the openURL alertView added in iOS 9, it can still be a big security issue.
Here is what I have tested:
iOS 5: the first installed app will be chosen. If you delete first installed app, then the others will not launch unless you install again.
iOS 6: the lastest installed app will be chosen. If you delete the lastest installed app, then the previous installed app will be chosen.
It will present an UIActionSheet view allowing the user to choose which app to launch (good example are apps that handle .doc files). That's where the icon you specify is used - on the action sheet buttons when it's shown to the user