Hello,
Welcome to Microsoft Q&A!
The returned value is always success.
This behavior is expected. The value indicates whether this method is running without error. When it returns success, there might be two different scenarios.
- The target app is installed, and it will be launched.
- The target app is not installed, and you will be guide to the Microsoft Store.
Both of the scenario means the LaunchUriAsync
method works correctly. Only if there are something wrong inside the LaunchUriAsync
method or the Launcher
object itself, the return value sill be failed.
Back to your question, you want to navigate to the Microsoft Store if the target app is not installed. As I've mentioned above, UWP has already implemented this in the LaunchUriAsync
method. Please check the LauncherOptions.FallbackUri Property. It's a value that represents a URI that the user should be taken to in the browser if no app exists to handle the file type or URI.
Please use the following code:
Uri appUri = new Uri("Testuri-alsdk:");
Uri appWinStoreUri = new Uri("https://www.microsoft.com/store/apps/xxxxx");
LauncherOptions options = new LauncherOptions();
options.FallbackUri = appWinStoreUri;
var success = await Windows.System.Launcher.LaunchUriAsync(appUri, options);
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.