Share via


LauncherOptions.FallbackUri Properti

Definisi

Mendapatkan atau menetapkan nilai yang mewakili URI yang harus dibawa pengguna di browser jika tidak ada aplikasi untuk menangani jenis file atau 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

Nilai Properti

URI yang harus dibawa pengguna di browser.

Contoh

Panggil metode Launcher.LaunchFileAsync(IStorageFile, LauncherOptions) | launchFileAsync(IStorageFile, LauncherOptions) dengan fallbackUri diatur ke URI 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

Keterangan

Anda hanya dapat mengatur properti URI fallback dengan URI http:// atau https://. Jika properti ini diatur dan tidak ada aplikasi yang diinstal untuk menangani file atau URI yang diluncurkan, browser default pengguna diluncurkan secara otomatis dan dinavigasi ke URI yang ditentukan. Pengguna tidak akan melihat dialog Buka Dengan yang meminta untuk memilih opsi dalam kasus ini. Anda hanya boleh menggunakan URI fallback saat mengarahkan pengguna ke Microsoft Store tidak sesuai, seperti kasus ketika file atau URI hanya didukung oleh aplikasi desktop yang tidak tercantum di Store. Dalam semua kasus di mana ada aplikasi di Microsoft Store yang mendukung file atau URI yang Anda luncurkan, Anda harus menggunakan PreferredApplicationPackageFamilyName dan PreferredApplicationDisplayName untuk merekomendasikan aplikasi tersebut kepada pengguna.

Anda tidak dapat mengatur properti aplikasi pilihan dan URI fallback secara bersamaan, karena hanya satu fallback yang dapat digunakan. LAUNCHER API akan gagal jika kedua fallback diatur.

Windows 8.1 Hanya di Windows 8.1, properti ini juga menerima URI Microsoft Store. URI ini dapat digunakan sebagai alternatif untuk properti PreferredApplicationPackageFamilyName dan PreferredApplicationDisplayName untuk mengirim pengguna ke aplikasi tertentu di Toko tanpa memunculkan dialog Buka Dengan . Fungsionalitas ini tidak didukung pada Windows Phone 8.1 atau aplikasi Windows 10 konvergen, dan penggunaannya tidak disarankan.

Berlaku untuk

Lihat juga