GetAppAndOptionalStorePackageUpdatesAsync Method does not work properly UWP

Sukanta Sutradhar 1 Reputation point
2022-10-11T12:10:58.05+00:00

I am trying to find out that is my current app version package has any update available or not... https://learn.microsoft.com/en-us/windows/uwp/packaging/self-install-package-updates this is not work properly while app current version and store version same. Anyone have any idea? How can I resolve this?

var context = StoreContext.GetDefault();  
IReadOnlyList<StorePackageUpdate> updates = await context.GetAppAndOptionalStorePackageUpdatesAsync();  
                  
if (updates.Count > 0)  
{  
    var version = updates[0].Package.Id.Version;  
    var storeVersion = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);  
  
    App.SLOG(LogLevel.Standard, $"Installed Version: {AppCommonMethods.GetAppVersion()} Store version: {storeVersion} Store version fullName: {updates[0].Package.Id.FullName} Package Description: {updates[0].Package.Description}");  
  
    if (!String.Equals(AppCommonMethods.GetAppVersion(), storeVersion))  
    {  
        UpdateAvailable = true;  
        RaisePropertyChanged("UpdateAvailable");  
    }  
}  

updates.Count always return grater then 0 in case of same version installed and StoreVersion always similar with installed version. Is there any specific way to get ms_store version? Why "updates.Count" return 1 in case of Similar version installed instead of 0 ?

Universal Windows Platform (UWP)
{count} votes