i am using this code
public static bool CheckForForceUpdate()
{
try
{
Version latestVersion = new(GetLatestVersion());
Version currentVersion = new(AppInfo.VersionString);
if (latestVersion != null && currentVersion < latestVersion)
{
NSUserDefaults.StandardUserDefaults.SetBool(true, StorageKey.IsForceUpdate);
return true;
}
else
{
NSUserDefaults.StandardUserDefaults.SetBool(false, StorageKey.IsForceUpdate);
return false;
}
}
catch (Exception ex)
{
Console.WriteLine("CheckForForceUpdate....." + ex.Message);
return false;
}
}
public static string GetLatestVersion()
{
try
{
string appId = "1586153397"; // Replace with your App Store app ID
string url = $"https://itunes.apple.com/lookup?id={appId}";
using (HttpClient client = new HttpClient())
{
var response = client.GetStringAsync(url).GetAwaiter().GetResult();
var json = JObject.Parse(response);
var latestVersion = json["results"]?[0]?["version"]?.ToString();
return latestVersion;
}
}
catch (Exception ex)
{
Console.WriteLine("GetLatestVersion..." + ex.Message);
return null;
}
}
The value of latestVersion should 2.1 in my production app i am not able to get this
hence i am not able to achieve Force Update functionality
Topic:
Community
SubTopic:
Apple Developers