Plugin.Maui.DeviceSession 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Plugin.Maui.DeviceSession --version 1.0.0
                    
NuGet\Install-Package Plugin.Maui.DeviceSession -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plugin.Maui.DeviceSession" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Plugin.Maui.DeviceSession" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Plugin.Maui.DeviceSession" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Plugin.Maui.DeviceSession --version 1.0.0
                    
#r "nuget: Plugin.Maui.DeviceSession, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Plugin.Maui.DeviceSession@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Plugin.Maui.DeviceSession&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Plugin.Maui.DeviceSession&version=1.0.0
                    
Install as a Cake Tool

Plugin.Maui.DeviceSession

NuGet

A .NET MAUI plugin for Android and iOS that gives you one API for:

  • Device identity (ANDROID_ID / identifierForVendor)
  • App installation identity (survives updates, resets on uninstall or data clear)
  • Analytics-style sessions (rotate after 30 minutes in the background by default)

Install

Package: https://www.nuget.org/packages/Plugin.Maui.DeviceSession

dotnet add package Plugin.Maui.DeviceSession

Or reference the project:

<ProjectReference Include="..\src\Plugin.Maui.DeviceSession\Plugin.Maui.DeviceSession.csproj" />

Register the plugin

builder
    .UseMauiApp<App>()
    .UseDeviceSession(options =>
    {
        options.EnableLogging = true;
        options.SessionTimeout = TimeSpan.FromMinutes(30);
        options.StartSessionOnInitialize = true;
        options.ResumeSessionAcrossProcessRestarts = true;
    });

Resolve IDeviceSession from dependency injection, or use DeviceSession.Current.

UseDeviceSession hooks Android OnResume/OnPause and iOS OnActivated/DidEnterBackground so sessions rotate automatically.

Read identity and session

var session = DeviceSession.Current;
var snapshot = session.Snapshot;

var deviceId = snapshot.Identity.DeviceId;
var installationId = snapshot.Installation.InstallationId;
var sessionId = snapshot.Session?.SessionId;

if (snapshot.Installation.IsFirstLaunch)
{
    // First run after install or data clear.
}

if (snapshot.Installation.IsUpdated)
{
    // First run after an app version change.
}

Manage sessions

session.SessionStarted += (_, e) => { /* persist e.Session.SessionId */ };
session.SessionEnded += (_, e) => { /* e.Reason is Manual, Timeout, or Reset */ };

session.StartSession();
session.EndSession();
session.NotifyForeground();
session.NotifyBackground();
session.ResetInstallation();

ResetInstallation clears persisted install/session state and creates a new installation id. The native device id is unchanged.

What each id means

Id Lifetime Android iOS
DeviceId Device / vendor scoped Settings.Secure.ANDROID_ID UIDevice.IdentifierForVendor
InstallationId This app install GUID in Preferences GUID in Preferences
SessionId Until background timeout (default 30 min) Same Same

Android ANDROID_ID is scoped to your app signing key (Android 8+) and changes after factory reset or a signing-key change.

iOS identifierForVendor changes if the user uninstalls every app from the same vendor.

InstallationId is the value to use when you need “this install of this app”. It survives updates and is cleared when the app is uninstalled or its data is wiped.

Host app setup

Android

No extra permissions or manifest entries are required.

iOS

The plugin stores install and session state in Preferences (User Defaults). Add the User Defaults reason to the iOS privacy manifest if you have not already:

<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>

Platform notes

Android iOS net10.0
Device id ANDROID_ID identifierForVendor Persisted fallback GUID
Installation / sessions Yes Yes Yes (for shared code and tests)

These identifiers are not secrets. Treat them as analytics/support identifiers and disclose them in your privacy policy if you send them off-device.

Sample

samples/DeviceSession.Sample shows device identity, installation flags, the current session, and reset.

dotnet build src/Plugin.Maui.DeviceSession/Plugin.Maui.DeviceSession.csproj
dotnet pack src/Plugin.Maui.DeviceSession/Plugin.Maui.DeviceSession.csproj -c Release
dotnet test tests/Plugin.Maui.DeviceSession.Tests/Plugin.Maui.DeviceSession.Tests.csproj
dotnet build samples/DeviceSession.Sample/DeviceSession.Sample.csproj -f net10.0-android

Pack

dotnet pack src/Plugin.Maui.DeviceSession/Plugin.Maui.DeviceSession.csproj -c Release

Packages are written to artifacts/.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Plugin.Maui.DeviceSession:

Package Downloads
Plugin.Maui.Observability

Umbrella telemetry pipeline for .NET MAUI on iOS and Android. Unifies AppHealth, NetworkMonitor, ApiResilience, BackgroundTasks, OfflineSync, SmartUpload, and DeviceSession into one signal stream, and exports to OpenTelemetry, Application Insights, Sentry, Datadog, Console, or a custom HTTP endpoint.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 61 9/2/2026
1.0.5 92 8/30/2026
1.0.4 92 8/30/2026
1.0.3 95 8/28/2026
1.0.2 93 8/28/2026
1.0.1 100 8/28/2026
1.0.0 105 8/27/2026

Initial release: native device IDs, installation identity, first-launch/update detection, and timeout-based sessions for Android and iOS.