Udostępnij za pośrednictwem


Package.GetAppInstallerInfo Method

Definition

Returns the .appinstaller XML file location. Use this method when you need to retrieve the .appinstaller XML file location for your app. For example, this is useful if your app needs to share a URI to its associated .appinstaller file. You can optionally add arguments to the URI.

public:
 virtual AppInstallerInfo ^ GetAppInstallerInfo() = GetAppInstallerInfo;
AppInstallerInfo GetAppInstallerInfo();
public AppInstallerInfo GetAppInstallerInfo();
function getAppInstallerInfo()
Public Function GetAppInstallerInfo () As AppInstallerInfo

Returns

The .appinstaller XML file location.

Windows requirements

Device family
Windows 10, version 1809 (introduced in 10.0.17763.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v7.0)

Examples

The following example generates an .appinstaller URI with arguments and creates an email to send the URI to another user. In this example, the ComposeEmailAsync method is assumed to be defined elsewhere.

AppInstallerInfo info = Windows.ApplicationModel.Package.Current.GetAppInstallerInfo();
if (info != null)
{
    // Uri that was used to install the app.
    // Example: http://contoso/connect4.appinstaller.
    Uri appInstallerUri = info.Uri;

    // Create the inner URI which uses a protocol handled by your app, passing any arguments needed in it 
    UriBuilder innerUriBuilder = new UriBuilder("my-app-protocol:");
    innerUriBuilder.Query = "difficulty=hard&highscore=9000";

    // Create outer URI builder for ms-appinstaller initializer link.
    UriBuilder outerUriBuilder = new UriBuilder("ms-appinstaller:");
    outerUriBuilder.Query =
        $"source={Uri.EscapeDataString(appInstallerUri.ToString())}&activationUri={Uri.EscapeDataString(innerUriBuilder.ToString())}";

    await ComposeEmailAsync(/* To */ colleagueEmail, /* Subject */ "Beat my high score!",
        /* Body */ outerUriBuilder.ToString());
}

Remarks

Use this method if you want to get the URI to the .appinstaller file associated with the current app so you can share the URI with users. If a user who doesn't have the app clicks the URI, they are taken through the install process for the app. If a user who already has the app clicks the URI, the app is updated if needed and then it opens.

You can optionally add arguments to the URI. In this case, the behavior is the same as described above, but the app can then use the arguments when it opens. The arguments must use a protocol that the app supports. For more information, see Handle URI activation.

Applies to

See also