Opening Google Play store from my app

Heinz Deubler 181 Reputation points
2021-01-30T01:44:44.973+00:00

I have a published app and in that app the user gets a notification when a new version is available. I created a button that when clicked the users is supposed to get redirected to the App Store or Google Play to that app so that he/she can update the app.

I found this code but I am getting the following error.

Device.OpenUri(new Uri("market://details?id=com.udemy.android"));  

BTW, the URI is valid

Error Message:
62172-error.png

Thank you in advance.

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Heinz Deubler 181 Reputation points
    2021-01-31T04:12:50.79+00:00

    I figured it out.

    var uri = "https://play.google.com/store/apps/details?id=com.udemy.com";
                if (await Xamarin.Essentials.Launcher.CanOpenAsync(uri))
                    await Xamarin.Essentials.Launcher.OpenAsync(uri);
    
    2 people found this answer helpful.
    0 comments No comments

  2. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
    2021-01-30T03:14:49.45+00:00

    Hello,

    Welcome to Microsoft Q&A!

    You can use latestversionplugin , this plugin helps to easily detect if you are running the latest version of your iOS, macOS, Android, or Windows app and open it in the App Store, Play Store, or Microsoft Store to update it.

    Usage

       using Plugin.LatestVersion;  
         
       var isLatest = await CrossLatestVersion.Current.IsUsingLatestVersion();  
         
       if (!isLatest)  
       {  
           var update = await DisplayAlert("New Version", "There is a new version of this app available. Would you like to update now?", "Yes", "No");  
         
           if (update)  
           {  
               await CrossLatestVersion.Current.OpenAppInStore();  
           }  
       }  
    

    Thank you.


    If the response is helpful, please click "Accept Answer" and upvote it.
    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.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.