Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Latest commit

 

History

History
85 lines (56 loc) · 3.06 KB

version-tracking.md

File metadata and controls

85 lines (56 loc) · 3.06 KB
title description ms.assetid author ms.author ms.date ms.custom no-loc
Xamarin.Essentials: Version Tracking
The VersionTracking class in Xamarin.Essentials lets you check the applications version and build numbers along with seeing additional information such as if it is the first time the application launched ever or for the current version, get the previous build information, and more.
670C7E8A-E882-4AC0-97D2-A53D90ADD6A3
jamesmontemagno
jamont
05/28/2019
video
Xamarin.Forms
Xamarin.Essentials

Xamarin.Essentials: Version Tracking

The VersionTracking class lets you check the applications version and build numbers along with seeing additional information such as if it is the first time the application launched ever or for the current version, get the previous build information, and more.

Get started

[!include]

Using Version Tracking

Add a reference to Xamarin.Essentials in your class:

using Xamarin.Essentials;

The first time you use the VersionTracking class it will start tracking the current version. You must call Track early only in your application each time it is loaded to ensure the current version information is tracked:

VersionTracking.Track();

After the initial Track is called version information can be read:

// First time ever launched application
var firstLaunch = VersionTracking.IsFirstLaunchEver;

// First time launching current version
var firstLaunchCurrent = VersionTracking.IsFirstLaunchForCurrentVersion;

// First time launching current build
var firstLaunchBuild = VersionTracking.IsFirstLaunchForCurrentBuild;

// Current app version (2.0.0)
var currentVersion = VersionTracking.CurrentVersion;

// Current build (2)
var currentBuild = VersionTracking.CurrentBuild;

// Previous app version (1.0.0)
var previousVersion = VersionTracking.PreviousVersion;

// Previous app build (1)
var previousBuild = VersionTracking.PreviousBuild;

// First version of app installed (1.0.0)
var firstVersion = VersionTracking.FirstInstalledVersion;

// First build of app installed (1)
var firstBuild = VersionTracking.FirstInstalledBuild;

// List of versions installed (1.0.0, 2.0.0)
var versionHistory = VersionTracking.VersionHistory;

// List of builds installed (1, 2)
var buildHistory = VersionTracking.BuildHistory;

Platform Implementation Specifics

All version information is stored using the Preferences API in Xamarin.Essentials and is stored with a filename of [YOUR-APP-PACKAGE-ID].xamarinessentials.versiontracking and follows the same data persistence outlined in the Preferences documentation.

API

Related Video

[!Video https://learn.microsoft.com/shows/XamarinShow/Version-Tracking-XamarinEssentials-API-of-the-Week/player]

[!include]