Skip to content

Latest commit

 

History

History
59 lines (41 loc) · 1.83 KB

packagecatalog_openforpackage_704953028.md

File metadata and controls

59 lines (41 loc) · 1.83 KB
-api-id -api-type
M:Windows.ApplicationModel.PackageCatalog.OpenForPackage(Windows.ApplicationModel.Package)
winrt method

Windows.ApplicationModel.PackageCatalog.OpenForPackage(Windows.ApplicationModel.Package)

-description

Allows listening to any Package and its dependents (optional, resource, and hostRuntime).

-parameters

-param package

The Package which will be monitored for notifications.

-returns

The PackageCatalog used to listen for deployment notifications.

-remarks

This API requires the PackageQuery capability (unless the call is for the current package).

This API allows a package to listen to deployment notifications for another package and its dependents (like PWAs).

-examples

This example uses the OpenForPackage method to listen to notifications on the current package (Package.Current). The event handler acts on any optional package that has finished updating.

void RegisterForDeploymentNotifications()
{
    if (catalog == null)
    {
        catalog = PackageCatalog.OpenForPackage(Package.Current);
        catalog.PackageUpdating += OptionalPackageUpdatingCallback;
    }
}

void OptionalPackageUpdatingCallback(object sender, PackageUpdatingEventArgs args)
{
    if (args.IsComplete && args.TargetPackage.IsOptional)
    {
        // Let the user know the Optional package has updated, and can be used now
        var messageDialog = new MessageDialog(args.TargetPackage.DisplayName + 
                        " has been updated. Please restart the app to enjoy our latest features.");
    }
}

-see-also

OpenForCurrentPackage,Package,PackageCatalog