Back to Uno

URI Launcher

doc/articles/features/windows-system.md

6.6-release-branch-cut7.1 KB
Original Source

URI Launcher

[!TIP] This article covers Uno-specific information for the Windows.System namespace. For a full description of the feature and instructions on using it, see Windows.System Namespace.

  • The Windows.System.Launcher class provides functionality for launching URIs and apps.

LaunchUriAsync

This API is supported on iOS, Android, WASM, and macOS.

On iOS, Android, and macOS the ms-settings: special URI is supported.

Platform-specifics

On iOS, launching the special URI opens the main page of system settings because deep-linking to specific settings is not available.

For WASM, launching the special URI will work properly only when opening the website on Windows. The method will return true even if the user cancels the application launch, as there is currently no way to detect if the app was successfully launched. When using LaunchUriAsync on WASM, note that there should be no await between user interaction (button click / command etc) and the Launcher invocation. Otherwise, the browser may ignore it due to security reasons.

In case of Android, we support the following nested URIs.

Settings URIAndroid Mapping
ms-settings:syncSettings.ActionSyncSettings
ms-settings:appsfeatures-appSettings.ActionApplicationDetailsSettings
ms-settings:appsfeaturesSettings.ActionApplicationSettings
ms-settings:defaultappsSettings.ActionManageDefaultAppsSettings
ms-settings:appsforwebsitesSettings.ActionManageDefaultAppsSettings
ms-settings:cortanaSettings.ActionVoiceInputSettings
ms-settings:bluetoothSettings.ActionBluetoothSettings
ms-settings:printersSettings.ActionPrintSettings
ms-settings:typingSettings.ActionHardKeyboardSettings
ms-settings:easeofaccessSettings.ActionAccessibilitySettings
ms-settings:network-airplanemodeSettings.ActionAirplaneModeSettings
ms-settings:network-celluarSettings.ActionNetworkOperatorSettings
ms-settings:network-datausageSettings.ActionDataUsageSettings
ms-settings:network-wifiSettingsSettings.ActionWifiSettings
ms-settings:nfctransactionsSettings.ActionNfcSettings
ms-settings:network-vpnSettings.ActionVpnSettings
ms-settings:network-wifiSettings.ActionWifiSettings
ms-settings:networkSettings.ActionWirelessSettings
ms-settings:personalizationSettings.ActionDisplaySettings
ms-settings:privacySettings.ActionPrivacySettings
ms-settings:aboutSettings.ActionDeviceInfoSettings
ms-settings:apps-volumeSettings.ActionSoundSettings
ms-settings:batterysaverSettings.ActionBatterySaverSettings
ms-settings:displaySettings.ActionDisplaySettings
ms-settings:screenrotationSettings.ActionDisplaySettings
ms-settings:quiethoursSettings.ActionZenModePrioritySettings
ms-settings:quietmomentshomeSettings.ActionZenModePrioritySettings
ms-settings:nightlightSettings.ActionNightDisplaySettings
ms-settings:taskbarSettings.ActionDisplaySettings
ms-settings:notificationsSettings.ActionAppNotificationSettings
ms-settings:storageSettings.ActionInternalStorageSettings
ms-settings:soundSettings.ActionSoundSettings
ms-settings:dateandtimeSettings.ActionDateSettings
ms-settings:keyboardSettings.ActionInputMethodSettings
ms-settings:regionlanguageSettings.ActionLocaleSettings
ms-settings:developersSettings.ActionApplicationDevelopmentSettings

In case of macOS, Uno supports the following nested URIs, mapped to Preference Panes (/System/Library/PreferencePanes)

Settings URImacOS Mapping
ms-settings:signinoptions-launchfaceenrollmentTouchID
ms-settings:launchfingerprintenrollmentTouchID
ms-settings:signinoptionsAccounts
ms-settings:emailandaccountsInternetAccounts
ms-settings:appsforwebsitesSettings.ActionManageDefaultAppsSettings
ms-settings:tabletmodeExpose
ms-settings:personalization-startExpose
ms-settings:personalization-backgroundDesktopScreenEffectsPref
ms-settings:personalizationAppearance
ms-settings:bluetoothBluetooth
ms-settings:dateandtimeDateAndTime
ms-settings:regionLocalization
ms-settings:typingKeyboard
ms-settings:displayDisplays
ms-settings:screenrotationDisplays
ms-settings:taskbarDock
ms-settings:batterysaverEnergySaver
ms-settings:powersleepEnergySaver
ms-settings:otherusersFamilySharingPrefPane
ms-settings:mousetouchpadMouse
ms-settings:devices-touchpadTrackpad
ms-settings:networkNetwork
ms-settings:privacy-notificationsNotifications
ms-settings:printersPrintAndFax
ms-settings:privacySecurity
ms-settings:crossdeviceSharingPref
ms-settings:quiethoursScreenTime
ms-settings:quietmomentshomeScreenTime
ms-settings:soundSound
ms-settings:windowsupdateSoftwareUpdate
ms-settings:cortana-windowssearchSpotlight
ms-settings:cortanaSpeech
ms-settings:storageStartupDisk
ms-settings:backupTimeMachine
ms-settings:easeofaccessUniversalAccessPref

Exceptions

  • When the uri argument is null, NullReferenceException is thrown. Note this differs from WinUI, where AccessViolationException is thrown.
  • When the method is called from a non-UI thread, InvalidOperationException is thrown.

Exceptions are in line with WinUI.

QueryUriSupportAsync

This API is supported on iOS, Android, and macOS, and the implementation does not respect the LaunchQuerySupportType parameter yet. It also reports the aforementioned special ms-settings URIs on Android and iOS as supported.

Platform-specific requirements

Android

When targeting Android 11 (API 30) or newer, you may notice the QueryUriSupportAsync returning false. To avoid this, make sure to add any URL schemes passed to it as <queries> entries in your AndroidManifest.xml:

xml
<queries>
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="tel" />
  </intent>

  <intent>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="https" />
  </intent>
</queries>

iOS

Add any URL schemes passed to QueryUriSupportAsync as LSApplicationQueriesSchemes entries in your Info.plist file, otherwise, it will return false:

xml
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>tel</string>
  <string>https</string>
</array>

Exceptions

  • When the uri argument is null, NullReferenceException is thrown. Note this differs from WinUI, where a plain Exception with HRESULT is thrown.

Exceptions are in line with WinUI.