Partilhar via


LauncherOptions.FallbackUri Propriedade

Definição

Obtém ou define um valor que representa um URI para o qual o usuário deve ser levado no navegador se nenhum aplicativo existir para manipular o tipo de arquivo ou o 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 da propriedade

URI para o qual o usuário deve ser levado no navegador.

Exemplos

Chame o método Launcher.LaunchFileAsync(IStorageFile, LauncherOptions) | launchFileAsync(IStorageFile, LauncherOptions) com fallbackUri definido como o URI de fallback.

// 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

Comentários

Você só pode definir a propriedade de URI de fallback com http:// ou URI de https://. Se essa propriedade estiver definida e não houver nenhum aplicativo instalado para manipular o arquivo ou o URI que está sendo iniciado, o navegador padrão do usuário será iniciado automaticamente e navegado para o URI especificado. O usuário não verá uma caixa de diálogo Abrir com solicitando para escolher uma opção nesse caso. Você só deve usar o URI de fallback ao direcionar o usuário para a Microsoft Store não for apropriado, como o caso em que o arquivo ou o URI só tem suporte por um aplicativo da área de trabalho que não está listado na Loja. Em todos os casos em que há um aplicativo na Microsoft Store que dá suporte ao arquivo ou URI que você está iniciando, você deve usar PreferredApplicationPackageFamilyName e PreferredApplicationDisplayName para recomendar esse aplicativo ao usuário.

Não é possível definir as propriedades preferenciais do aplicativo e o URI de fallback ao mesmo tempo, pois apenas um fallback pode ser usado. A API do Inicializador falhará se ambos os fallbacks forem definidos.

Windows 8.1 somente em Windows 8.1, essa propriedade também aceita URIs da Microsoft Store. Esses URIs podem ser usados como uma alternativa às propriedades PreferredApplicationPackageFamilyName e PreferredApplicationDisplayName para enviar o usuário para um aplicativo específico na Loja sem abrir uma caixa de diálogo Abrir com . Essa funcionalidade não tem suporte em aplicativos do Windows 10 Windows Phone 8.1 ou convergidos e seu uso não é recomendado.

Aplica-se a

Confira também