App information

This article describes how you can use the .NET Multi-platform App UI (.NET MAUI) IAppInfo interface, which provides information about your application. The IAppInfo interface is exposed through the AppInfo.Current property.

The AppInfo and IAppInfo types are available in the Microsoft.Maui.ApplicationModel namespace.

Read the app information

There are four properties exposed by the IAppInfo interface:

  • IAppInfo.Name — The application name
  • IAppInfo.PackageName — The package name or application identifier, such as com.microsoft.myapp.
  • IAppInfo.VersionString — The application version, such as 1.0.0.
  • IAppInfo.BuildString — The build number of the version, such as 1000.

The following code example demonstrates accessing these properties:

string name = AppInfo.Current.Name;
string package = AppInfo.Current.PackageName;
string version = AppInfo.Current.VersionString;
string build = AppInfo.Current.BuildString;

Read the current theme

The RequestedTheme property provides the current requested theme by the system for your application. One of the following values is returned:

  • Unspecified
  • Light
  • Dark

Unspecified is returned when the operating system doesn't have a specific user interface style. An example of this is on devices running versions of iOS older than 13.0.

The following code example demonstrates reading the theme:

ThemeInfoLabel.Text = AppInfo.Current.RequestedTheme switch
{
    AppTheme.Dark => "Dark theme",
    AppTheme.Light => "Light theme",
    _ => "Unknown"
};

Display app settings

The IAppInfo class can also display a page of settings maintained by the operating system for the application:

AppInfo.Current.ShowSettingsUI();

This settings page allows the user to change application permissions and perform other platform-specific tasks.

Platform implementation specifics

This section describes platform-specific implementation details related to the IAppInfo interface.

App information is taken from the AndroidManifest.xml for the following fields:

  • Buildandroid:versionCode in manifest node
  • Nameandroid:label in the application node
  • PackageNamepackage in the manifest node
  • VersionStringandroid:versionName in the application node

Requested theme

Android uses configuration modes to specify the type of theme to request from the user. Based on the version of Android, it can be changed by the user or may be changed when battery saver mode is enabled.

You can read more on the official Android documentation for Dark Theme.