File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Microsoft.Toolkit.Uwp/Helpers Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,12 @@ public static async Task LaunchStoreForReviewAsync()
121121 /// </summary>
122122 public PackageVersion FirstVersionInstalled { get ; }
123123
124+ /// <summary>
125+ /// Gets the previous version of the app that was installed.
126+ /// This will be the current version if a previous version of the app was installed before accessing this property.
127+ /// </summary>
128+ public PackageVersion PreviousVersionInstalled { get ; }
129+
124130 /// <summary>
125131 /// Gets the DateTime (in UTC) when the app was launched for the first time.
126132 /// </summary>
@@ -310,6 +316,7 @@ private SystemInformation()
310316 IsAppUpdated = DetectIfAppUpdated ( ) ;
311317 FirstUseTime = DetectFirstUseTime ( ) ;
312318 FirstVersionInstalled = DetectFirstVersionInstalled ( ) ;
319+ PreviousVersionInstalled = DetectPreviousVersionInstalled ( ) ;
313320 InitializeValuesSetWithTrackAppUse ( ) ;
314321 }
315322
@@ -382,6 +389,23 @@ private PackageVersion DetectFirstVersionInstalled()
382389 return result ;
383390 }
384391
392+ private PackageVersion DetectPreviousVersionInstalled ( )
393+ {
394+ PackageVersion result ;
395+
396+ if ( _localObjectStorageHelper . KeyExists ( nameof ( PreviousVersionInstalled ) ) )
397+ {
398+ result = _localObjectStorageHelper . Read < string > ( nameof ( PreviousVersionInstalled ) ) . ToPackageVersion ( ) ;
399+ }
400+ else
401+ {
402+ result = ApplicationVersion ;
403+ _localObjectStorageHelper . Save ( nameof ( PreviousVersionInstalled ) , ApplicationVersion . ToFormattedString ( ) ) ;
404+ }
405+
406+ return result ;
407+ }
408+
385409 private void InitializeValuesSetWithTrackAppUse ( )
386410 {
387411 LaunchTime = DateTime . MinValue ;
You can’t perform that action at this time.
0 commit comments