Skip to content
Shiny.NET
Shiny MAUI Shell v7 - App Links, App Shortcuts, & Navigation Interception!Shortcut me to it

Platform Preferences

NuGet package Shiny.Extensions.Configuration

The Platform Preferences provider wraps the native platform preferences (Android SharedPreferences, iOS NSUserDefaults) as an IConfiguration source. Unlike most providers, this one supports write-back - you can set values via IConfiguration and they will be persisted across app restarts.

var config = new ConfigurationBuilder()
.AddPlatformPreferences()
.Build();

You can write values directly through IConfiguration:

IConfiguration config = ...; // build
config["key"] = "value"; // persists to platform preferences

Writing a value will:

  1. Persist the value to the platform’s native preferences store
  2. Trigger change notifications via IOptionsMonitor<T>

When combined with IOptionsMonitor<T>, you get reactive updates whenever a preference value changes:

services.Configure<MySettings>(config.GetSection("MySettings"));
// In your service/viewmodel
public class MyService
{
public MyService(IOptionsMonitor<MySettings> options)
{
options.OnChange(settings =>
{
// React to configuration changes
});
}
}
Platform Backing Store
Android SharedPreferences
iOS / Mac Catalyst NSUserDefaults