One common scenario that developers often need to integrate into an app, is showing a prompt when an app is launched for the first time. This could be to display a disclaimer or to walk users through the functionality of the app. This can be done on first launch of the app. Even after install or for a specific version. Using Xamarin.Essentials helps integrate this functionality with a just few lines of code.
A way to determine the first run is to leverage the built-in preferences API. This stores a boolean value that can be checked at runtime. For example, create a Settings
class with a FirstRun
property set the default value to true
:
public static class Settings
{
public static bool FirstRun
{
get => Preferences.Get(nameof(FirstRun), true);
set => Preferences.Set(nameof(FirstRun), value);
}
}
Next, check the value at startup to confirm if the value is true
. Then perform an action and set the value to false
:
if(Settings.FirstRun)
{
// Perform an action such as a "Pop-Up".
Settings.FirstRun = false;
}
#developers #integrations #mobile applications #mobile apps #version tracking