Share via


LauncherOptions.FallbackUri Propiedad

Definición

Obtiene o establece un valor que representa un URI al que se debe llevar el usuario en el explorador si no existe ninguna aplicación para controlar el tipo de archivo o el URI.

public:
 property Uri ^ FallbackUri { Uri ^ get(); void set(Uri ^ value); };
Uri FallbackUri();

void FallbackUri(Uri value);
public System.Uri FallbackUri { get; set; }
var uri = launcherOptions.fallbackUri;
launcherOptions.fallbackUri = uri;
Public Property FallbackUri As Uri

Valor de propiedad

URI al que se debe llevar el usuario en el explorador.

Ejemplos

Llame al método Launcher.LaunchFileAsync(IStorageFile, LauncherOptions) | launchFileAsync(IStorageFile, LauncherOptions) con fallbackUri establecido en el URI de reserva.

// The URI to launch
string uriToLaunch = @ "contoso:somearguments";
var uri = new Uri(uriToLaunch);

// The fallback URI
string uriFallback = @ "http://www.contoso.com/somearguments";
var fallbackUri = new Uri(fallbackUri);

async void DefaultLaunch()
{
   // Set the fallback URI
   var options = new Windows.System.LauncherOptions();
   options.FallbackUri = fallbackUri;

   // Launch the URI with the fallback URI
   var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

   if (success)
   {
      // URI launched
   }
   else
   {
      // URI launch failed
   }
}
// The URI to launch.
Windows::Foundation::Uri m_uri{ L"contoso:somearguments" };

// The fallback URI.
Windows::Foundation::Uri m_fallbackUri{ L"http://www.contoso.com/somearguments" };

Windows::Foundation::IAsyncAction MainPage::DefaultLaunch()
{
    // Set the fallback URI.
    Windows::System::LauncherOptions launcherOptions;
    launcherOptions.FallbackUri(m_fallbackUri);

    // Launch the URI.
    if (co_await Windows::System::Launcher::LaunchUriAsync(m_uri, launcherOptions))
    {
        // URI launched.
    }
    else
    {
        // URI launch failed.
    }
}
// The URI to launch
auto uri = ref new Windows::Foundation::Uri("contoso:somearguments");

// The fallback URI
auto fallbackUri = ref new Windows::Foundation::Uri("http://www.contoso.com/somearguments");

void MainPage::DefaultLaunch()
{
   // Set the fallback URI
   auto launchOptions = ref new Windows::System::LauncherOptions();
   launchOptions->FallbackUri = fallbackUri;

   // Launch the URI with the fallback URI
   concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri, launchOptions));
   launchUriOperation.then([](bool success)
   {
      if (success)
      {
         // URI launched
      }
      else
      {
         // URI launch failed
      }
   });
}
' The URI to launch
Dim uri As New Uri("contoso:somearguments")

' The fallback URI
Dim fallbackUri As New Uri("http://www.contoso.com/somearguments")

async Sub DefaultLaunch()

   ' Set the fallback URI
   Dim options = Windows.System.LauncherOptions()
   options.FallbackUri = fallbackUri

   ' Launch the URI with the fallback URI
   Dim success = await Windows.System.Launcher.LaunchUriAsync(uri, options)

   If success Then
      ' URI launched
   Else
      ' URI launch failed
   End If

End Sub

Comentarios

Solo puede establecer la propiedad URI de reserva con http:// o https:// URI. Si se establece esta propiedad y no hay ninguna aplicación instalada para controlar el archivo o el URI que se está iniciando, el explorador predeterminado del usuario se inicia automáticamente y se desplaza al URI especificado. El usuario no verá un cuadro de diálogo Abrir con en el que se le pide que elija una opción en este caso. Solo debes usar el URI de reserva al dirigir al usuario a Microsoft Store, como el caso cuando el archivo o el URI solo es compatible con una aplicación de escritorio que no aparece en la Tienda. En todos los casos en los que hay una aplicación en Microsoft Store que admite el archivo o el URI que estás iniciando, debes usar PreferredApplicationPackageFamilyName y PreferredApplicationDisplayName para recomendar esa aplicación al usuario.

No se pueden establecer las propiedades preferidas de la aplicación y el URI de reserva al mismo tiempo, ya que solo se puede usar una reserva. Se producirá un error en la API del iniciador si se establecen ambas reservas.

Windows 8.1 Solo en Windows 8.1, esta propiedad también acepta URI de Microsoft Store. Estos URI se pueden usar como alternativa a las propiedades PreferredApplicationPackageFamilyName y PreferredApplicationDisplayName para enviar al usuario a una aplicación específica de la Tienda sin que aparezca un cuadro de diálogo Abrir con . Esta funcionalidad no se admite en Windows Phone 8.1 ni en aplicaciones convergentes de Windows 10 y no se recomienda su uso.

Se aplica a

Consulte también