Is there a way to use or an alternative to InstallationManager.FindPackagesForCurrentPublisher? It looks like it is only for the phone.
I know you can launch an app by creating and then launching a URI, but I need to know if the app I want to launch is installed.
EDIT:
The app I want to launch is by the same publisher.
If we use the LaunchUriAsync(Uri)
method to launch an app, system will firstly try to launch the installed app which registered this protocol, if the target app is not installed, then it will open the Store app and show the recommended apps which registered this protocol.
FindPackagesForCurrentPublisher
method can only find the app packages with the same publisher ID as your app, for other app which is not with the same publisher, you will need to use FindPackages method, and this method requires ID_CAP_OEM_DEPLOYMENT
. For desktop, there is no method now, you need special access to do that work, otherwise you can't break the sand box of UWP app.
But if your app won't be published into the Store, there is method which use PackageManager class to find the installed package. To use this class, you will need to add packageManagement
capability into your app's manifest like this:
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
...
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="packageManagement" />
</Capabilities>
</Package>
For this capability, you can refer to Special and restricted capabilities.
At last you can use this class in your app, for example list all the installed packages:
var packageManager = new PackageManager();
IEnumerable<Windows.ApplicationModel.Package> packages = (IEnumerable<Windows.ApplicationModel.Package>)packageManager.FindPackagesForUser("");
var list = packages.ToList();