waqas waqas
waqas waqas

Reputation: 237

How to check version number and open app in App(iTunes)Store (iOS)?

I need to check current version of Installed Application. If it is not same app should navigate to app page in app store.

I am using latest version plugin for this. Its working fine with Android but not with iOS

Setings.appVersion = await CrossLatestVersion.Current.GetLatestVersionNumber();
if (Setings.appVersion == "1.0.1")
{
     MainPage = new NavigationPage(new Login());
}
else
{
     //lblBuildNumber.Text = DependencyService.Get<IAppVersionAndBuild>().GetBuildNumber();
     MainPage = new NavigationPage(new UpdateAppPopup());
}


async void  Handle_Clicked(object sender, System.EventArgs e)
{
      await CrossLatestVersion.Current.OpenAppInStore("com.KIH.Consultant");
}

with this code it should navigate to app page in app store or playstore its wokring with fine with playstore, but not working in appstore(ios)

Upvotes: 0

Views: 821

Answers (2)

prasadsunny1
prasadsunny1

Reputation: 830

use Xamarin.Essentials to get the current version string and version code for the app.

// Application Version (1.0.0)
var version = AppInfo.VersionString;

// Application Build Number (1)
var build = AppInfo.BuildString;

Upvotes: 1

Hitesh Patil
Hitesh Patil

Reputation: 380

1) Create One Interface Inside Your Main Project

public interface IAppService
{
  string GetVersion();
}

2) Then Implement it inside your droid project

public class AppService : IAppService
{

    public string GetVersion() {
    var context = Android.App.Application.Context;
    var info = context.PackageManager.GetPackageInfo(context.PackageName, 
    Android.Content.PM.PackageInfoFlags.MatchAll);
    return info.VersionName;
}

3) Then Implement it inside your ios project

public class AppService : IAppService
{
    public string GetVersion()
    {
        return NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString();
    }
}

4) Now you can use it like this

string v = Get<IAppService>().GetVersion();

Upvotes: 1

Related Questions