The SDK in .NET

.NET apps use the SDK through its package, Squiddy, with one C# API on the desktops (Windows, Linux and macOS: WinUI, WPF, Windows Forms, console, .NET MAUI on Windows) and in .NET MAUI on Android and iOS: SquiddyClient, whose values are observables with their value now, a Changed event and IObservable<T>, whose calls return tasks, whose durations are TimeSpans and whose refusals are exceptions with the names of the SDK's errors. The package is a thin bridge: it carries the SDK of each system, of its own version, and calls it, so a .NET app has the same stored configuration, conditional checks, backoff, gate and languages as a native one. What the SDK does, what the API key allows and how the SDK behaves offline are on the SDK page; this page is the integration.

Install

dotnet add package Squiddy --version 0.9.0

or, in the project file, <PackageReference Include="Squiddy" Version="0.9.0" />. The package is on nuget.org, at version 0.9.0, the same release as on the other platforms: in a 0.x version a minor version may change the API.

Windows, Linux, macOSAndroid (.NET MAUI)iOS (.NET MAUI)
Targetnet10.0, net10.0-windowsnet10.0-androidnet10.0-ios
Minimum.NET 10; Windows x64, Linux x64 and arm64 with glibc, macOS 12 (Apple silicon and Intel)API 24iOS 15
What the package runsthe SDK's C library for the app's runtime, which the package carries in runtimes/<runtime>/native/the SDK's Android library, cloud.squiddy:squiddy-android, which the package carries with the Java libraries it needsthe SDK's C library, linked statically into the app from the package's squiddy.xcframework
app_type sent to Squiddydesktopandroidios
Bundle idBundleId, or none with a storage directory (a macOS app bundle has its own)the application idthe main bundle's identifier
Storage%LOCALAPPDATA%\<bundle id>\squiddy on Windows, ~/.local/share/<bundle id>/squiddy on Linux, ~/Library/Application Support/<bundle id>/squiddy on macOS, or the storage directory giventhe app's no-backup files directoryLibrary/Application Support/squiddy, excluded from backups
Push updateno: Firebase Cloud Messaging has no client for the desktopsyesyes

What each system asks of the app:

Keep the key out of the repository

The key ends up inside the app, so it is not a secret (see the API key), but like any credential it does not belong in the repository. One way, the sample's: a JSON file that git ignores, which the build embeds in the app when it exists.

<ItemGroup>
  <EmbeddedResource Include="squiddy.local.json" LogicalName="squiddy.local.json"
                    Condition="Exists('squiddy.local.json')" />
</ItemGroup>
using var stream = typeof(MauiProgram).Assembly.GetManifestResourceStream("squiddy.local.json");

A pipeline writes the same file from a secret variable before it builds. A desktop app on a server can read the key from its environment or its configuration instead, as any credential.

Initialize

Create one instance per app and Squiddy environment, when the app starts, and keep it for the life of the app: in a MAUI app, in the Application or as a singleton of the app's services. There is no global instance and no automatic start.

using Squiddy;

var squiddy = await SquiddyClient.InitializeAsync(new SquiddyOptions
{
    Host = "https://squiddy.example.com",
    ApiKey = settings.ApiKey,
    AppId = "my-app",
    AppVersion = "2026.12.01", // YYYY.MM.DD: Squiddy compares it as a number
#if DEBUG
    AppMode = "debug",
#else
    AppMode = "release",
#endif
}, eventContext: SynchronizationContext.Current); // the interface's thread, to receive the values there

On the desktops, where the SDK cannot read an identifier of the app, give BundleId (com.example.app), which names the folder of the SDK's files, or a folder of the app's own as the second argument, storageDirectory; a macOS app bundle has its own identifier. On Android and iOS the SDK reads the app's identifier and its folders itself.

InitializeAsync hands the options to the SDK, which checks every one before it starts, and returns without waiting for the disk or the network: Config.Value is Pending until the stored configuration is read. Options the SDK refuses throw a SquiddyInitializationException, whose Error is InvalidOptions (a missing or empty option, a version that is not YYYY.MM.DD, a host that is not an http or https URL) or StorageUnavailable (no place for the files), and whose Message names the option to fix. CloseAsync stops the updates and keeps the values readable; Dispose (or await using) also frees the SDK's native instance.

Options

Only the first five are required (required members).

OptionDefaultWhat it does
Host, ApiKey, AppId, AppVersion, AppMode—Required. AppVersion is YYYY.MM.DD; AppMode is matched against the configuration's modes, such as debug and release
CustomParamsnoneThe custom parameters the configuration's rules match, sent as given
BundleIdthe system's (see Install)Another identifier, sent as given; on the desktops it names the folder of the files
Languagethe system'sA language of the app's own, sent as given; SetLanguageAsync changes it later
EntityIdthe installation idAn opaque id of yours that rollouts place the user by (see rollouts)
Timeout10 secondsThe longest one call may take, a TimeSpan of whole milliseconds
PushRefreshJitterup to 1 minuteThe longest random wait before the check a push update asks for, a TimeSpan of whole milliseconds, so the installations do not call at the same instant
LoggernoneA SquiddyLogger delegate, (level, message, cause): Debug lines show the HTTP headers with the key redacted, Warning lines the problems the SDK recovered from. It runs on a thread of the SDK

The options never print the key: SquiddyOptions is a class, not a record. How often the SDK checks while the app is in the foreground is not an option: the configuration decides it with the refreshInterval of its API block, and by default there is no periodic check (the periodic check).

The configuration

Config, Gate and Strings are observables of the SDK's values: Value is the value now, Changed is raised with every change, and Subscribe (an IObservable<T>) gives an observer the value now, then every change, until the subscription is disposed. A value the SDK repeats is not a change.

squiddy.Config.Changed += (_, state) =>
{
    var timeout = state.Configuration?.ServerApi?.Setting("timeout")?.AsInt() ?? 30;
    ApplyTimeout(timeout);
};

Without an eventContext the values arrive on a thread of the SDK, one at a time and in order; with one, such as the SynchronizationContext of the interface's thread (WPF, WinUI, Windows Forms, MAUI), they are posted to it, in order, and Value changes there, just before Changed, so a page reads a value that agrees with the event. An exception of a handler is the app's: with a context it reaches the context's handler of unhandled exceptions, without one it is unhandled on a thread of the pool.

A SquiddyState has a Kind: Pending, Ready or Failed. A Ready state has its Origin, Cache from the device's storage or Network once Squiddy sent or confirmed it; a Failed one has its Error and the configuration still served. A RemoteConfiguration has its Version, its ServerApi (BaseUrl, Mode, ApiVersion, IsDebugActive and Settings, with Setting(key)), its two notices AppUpdate (IsRequired) and InfoPoint (IsHalting), and its Strings. A setting reads as text with Value, or with AsInt(), AsDouble() and AsBoolean(), which throw a SettingTypeException (a FormatException) naming the setting when the value is not of that type.

The gate

Gate says which screen the app shows: its Kind is None, UpdateRequired or Maintenance.

squiddy.Gate.Changed += (_, gate) =>
{
    switch (gate.Kind)
    {
        case AppGateKind.UpdateRequired: ShowUpdatePage(gate.Title, gate.Message); break;
        case AppGateKind.Maintenance: ShowMaintenancePage(gate.Title, gate.Message); break;
        default: ShowApp(); break;
    }
};

UpdateRequired comes from an app-update notice marked as required for this version, Maintenance from an info-point notice that halts the app, and when both apply maintenance wins. Titles and messages arrive already localized by Squiddy; a title or a message left blank for the language arrives empty, and the gate applies all the same. The gate holds for the configuration read from the device too, so a maintenance stays on screen offline, and it is None while there is no configuration at all.

The kinds are closed sets: until 1.0.0 a minor version may add a member, and says so in the changelog, so a switch with a default keeps working and one without it should handle the new member.

Strings

var title = squiddy.String("welcome_title", fallback: "Welcome");

String reads the strings the SDK delivered last, at once, so it serves while a page is built. A string is looked up in the language the SDK asks in, then in the configuration's default language, then the fallback (null without one), and only a key the language does not have goes on to the next. An empty text is a text: a translation left blank in the dashboard is returned empty, with or without the fallback, so a key left blank in a language stays blank in the app. Strings is the value of all of them, a LocalizedStrings with its own String(key, fallback). The configuration holds every language its API block supports, so a change of language changes the strings without a call.

Language

The SDK asks Squiddy in the system's language. An app with its own language picker calls await squiddy.SetLanguageAsync("en"), and SetLanguageAsync(null) goes back to the system's; a blank language throws a SquiddyLanguageException (InvalidLanguage). When the language changes, the strings switch with the SDK's next value, a moment later (Strings delivers them), and the SDK checks with Squiddy, in the foreground, for the texts of the notices, which Squiddy localizes for each call.

When the SDK checks

As the SDK of the system does: at every start, after serving the stored configuration; whenever the app comes back to the foreground; and, if the API block of the configuration has a refreshInterval, at that interval while it stays there (the periodic check). On Android and iOS the foreground is the app's, as in a native app; on Windows and Linux an app is always in the foreground, so it checks at start and at the configuration's refreshInterval; on macOS, while one of its windows is visible, and an app without windows as on Windows (macOS). In the background it makes no call. await squiddy.RefreshAsync() asks for a check now, and the outcome arrives in Config.

Push update

Push update is a button on each configuration in the dashboard: Squiddy sends a data-only message of Firebase Cloud Messaging to the configuration's topic, and every installation subscribed to it checks within a random wait of up to PushRefreshJitter. The package does not depend on Firebase: a MAUI app subscribes to the topic the SDK gives it, squiddy.PushTopic, with the Firebase binding of each system, and hands the data of the messages it receives to HandlePushAsync. On the desktops there is no push update: the SDK checks at start and at the configuration's refreshInterval.

What it takes is what the native apps need: a Firebase project with the app's Android and Apple apps, on iOS the Push Notifications capability, the Remote notifications background mode and an APNs key uploaded to Firebase (see the push update on Android and iOS), and the project's service account key uploaded to the configuration's Push update tab in the dashboard.

On Android, with Microsoft's binding Xamarin.Firebase.Messaging, start Firebase, subscribe, and hand the data that reaches the app's messaging service to the SDK:

await FirebaseMessaging.Instance.SubscribeToTopic(squiddy.PushTopic);

[Service(Exported = false)]
[IntentFilter(["com.google.firebase.MESSAGING_EVENT"])]
public sealed class AppMessagingService : FirebaseMessagingService
{
    public override void OnMessageReceived(RemoteMessage message) =>
        _ = App.Squiddy?.HandlePushAsync(message.Data.ToDictionary());
}

On iOS, with the community's binding of Google's frameworks AdamE.Firebase.iOS.CloudMessaging, register for remote notifications, hand Firebase the APNs token, subscribe once it has it, and hand the data of each remote notification to the SDK, in the app delegate:

UIApplication.SharedApplication.RegisterForRemoteNotifications();
// application:didRegisterForRemoteNotificationsWithDeviceToken:
Messaging.SharedInstance.ApnsToken = deviceToken;
await Messaging.SharedInstance.SubscribeAsync(squiddy.PushTopic);
// application:didReceiveRemoteNotification:fetchCompletionHandler:
await squiddy.HandlePushAsync(userInfo.ToDictionary(entry => entry.Key.ToString(), entry => entry.Value.ToString()));

HandlePushAsync returns true for Squiddy's message, whose data says squiddy = refresh and names its topic in squiddy_topic, and false for any other, which stays the app's. The messages reach the SDK while the app's process runs with its instance; a message that arrives before the app has started the SDK is left, and the SDK checks at its start and whenever the app comes back to the foreground.

The topic is squiddy- and 64 hexadecimal digits, computed from the API key and the AppId: every installation that reads the same configuration with the same key shares it. A version of the app with another key has another topic: keep the topic you subscribed to and, when PushTopic differs, unsubscribe from the old one.

Errors

A failed check is a Failed state whose Error is a SquiddyError with a Kind, a Message, RetryAfterSeconds (for RateLimited, when Squiddy said how long) and ExceptionCode (for ServerError, when Squiddy sent one). The kinds have the names of the table of errors: Unauthenticated, AppNotPublished, IncompleteConfiguration, InvalidRequest, TenantSuspended, RateLimited, ServerError, Network, Timeout and MalformedResponse.

if (squiddy.Config.Value.Error?.Kind == SquiddyErrorKind.TenantSuspended) TellSomeone();

No other exception leaves the package, except SquiddyInitializationException from InitializeAsync, SquiddyLanguageException from SetLanguageAsync, SettingTypeException from a typed reading of a setting, the ArgumentExceptions of a null argument or an empty storage directory, an ObjectDisposedException for a call after Dispose, and an InvalidOperationException that names the SDK's function for a defect of the SDK, to be reported.

The sample

The SDK's repository has a .NET MAUI sample, on Android and iOS, with the screen of the other samples: the state of the configuration with a button that checks now, the gate, a localized string, a language picker, the configuration's settings, and the push update with Firebase Cloud Messaging. It starts the SDK once with the interface's context, reads the configuration squiddy-sample, with the key in a squiddy.local.json that git ignores and the build embeds, and keeps its Firebase options in the same file, so it needs neither google-services.json nor GoogleService-Info.plist.