The Squiddy SDK
The Squiddy SDK is the library an app reads its configuration with. It is one Kotlin Multiplatform library, version 0.9.0, for Android, the JVM, iOS, macOS, tvOS, Linux, Windows, the browser, Node.js, Flutter, React Native and .NET: it makes the data-plane call for the app, keeps the last valid configuration on the device, in the browser or on the server, serves it at once at the next start, with or without a network, and follows the configuration while the app runs.
Each platform has a guide, from the installation to the errors. The table links it, and gives the platform's package, the line that installs it and the oldest system, runtime or toolchain it needs, which the guide details. A native program for Linux or Windows is written with Kotlin Multiplatform or with .NET.
| Platform | Guide | Package | Minimum |
|---|---|---|---|
| Android | SDK for Android and the JVM | cloud.squiddy:squiddy, with implementation("cloud.squiddy:squiddy:0.9.0") in build.gradle.kts | API 24 |
| JVM | SDK for Android and the JVM | cloud.squiddy:squiddy, with implementation("cloud.squiddy:squiddy:0.9.0") in build.gradle.kts | Java 17 |
| iOS | SDK for iOS | squiddy-cloud/squiddy-swift, with .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0") in Package.swift | iOS 15, Swift 5.9 |
| macOS | SDK for macOS | squiddy-cloud/squiddy-swift, with .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0") in Package.swift | macOS 12, Swift 5.9 |
| tvOS | SDK for tvOS, visionOS and watchOS | squiddy-cloud/squiddy-swift, with .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0") in Package.swift | tvOS 15, Swift 5.9 |
| visionOS | SDK for tvOS, visionOS and watchOS | squiddy-cloud/squiddy-swift, with .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0") in Package.swift | iOS 15, Swift 5.9 |
| Kotlin Multiplatform | SDK in Kotlin Multiplatform | cloud.squiddy:squiddy, with implementation("cloud.squiddy:squiddy:0.9.0") in build.gradle.kts | Kotlin 2.4 |
| Browser | SDK on the web | @squiddy-cloud/sdk, with npm install @squiddy-cloud/sdk@0.9.0 | ES modules, fetch, localStorage |
| Node.js | SDK on the web | @squiddy-cloud/sdk, with npm install @squiddy-cloud/sdk@0.9.0 | Node.js 22.3 |
| Flutter | SDK for Flutter | squiddy_flutter, with squiddy_flutter: ^0.9.0 in pubspec.yaml | Flutter 3.50.1 |
| React Native | SDK for React Native | @squiddy-cloud/react-native, with npm install @squiddy-cloud/react-native@0.9.0 | React Native 0.88 |
| React | SDK on the web | @squiddy-cloud/react, with npm install @squiddy-cloud/react@0.9.0 @squiddy-cloud/sdk@0.9.0 | React 18 |
| .NET | SDK for .NET | Squiddy, with dotnet add package Squiddy --version 0.9.0 | .NET 10 |
The SDK is free software under the Apache License 2.0, a licence of its own: an app embeds it whatever the app's licence is. It is in its 0.x series, so until 1.0.0 a minor version may change the API. Every change of every version is in the changelog, published with the Swift package and the same for every platform.
Coming soon
The SDK is being extended to these platforms, which it does not support yet. None of them has a package, a guide or a date: the release that brings one moves it to the table above, with its package and its guide.
- watchOS, in Swift
- Unity, in C#
What the SDK does
- It calls the data plane for you: the procedure of the quickstart, in binary Connect, with the API key in the
X-API-Keyheader and nowhere else. It fills in the app's identity itself: the platform (android,ios,tvoson an Apple TV,desktopon the JVM, on macOS and natively on Linux and Windows, orwebin a browser and in Node.js), the bundle id (a page's is its host name; a JVM application, a native program on Linux or Windows, a .NET desktop app or a Node.js server gives one, having none), the language and the installation id. The app gives the rest: theappId, its version asYYYY.MM.DD, its mode, and its custom parameters if it has any. - It keeps the configuration on the device. Every start serves the stored configuration before any call, then checks it with Squiddy. A check sends the fingerprint of what the device holds, so an unchanged configuration is answered
not_modified, a few hundred bytes. - It checks while the app is used: at every start, whenever the app comes back to the foreground (a page: whenever it becomes visible), and, only if the configuration asks for it, at intervals while it stays there (the periodic check, off by default). Never in the background: no timer runs there.
refresh()checks at once, and so does a change of language in the foreground. - It answers the update notification. Whoever manages the configuration can press Push update in the dashboard: the installations that subscribed to Firebase Cloud Messaging check within a random wait of up to a minute by default, in the background too (see the push update on Android, on iOS, on macOS and on tvOS; a Flutter, React Native or .NET MAUI app hands it to the SDK while it runs, and a page cannot subscribe).
- It reads the answer for the app: the state of the configuration, the gate (update required, maintenance), and the localized strings with their fallback, each as a value the app reads now or observes.
What you need from Squiddy
- The host: the origin your Squiddy is served on, the scheme and host of the dashboard's address, with no trailing slash.
- A data-plane API key of the environment the app reads, from the dashboard's API keys page. One key serves every app of its environment: the
appIdtells the apps apart. - A published configuration for the app's
appIdin that environment, with an API block that matches the app: its platform (android,ios,tvos,desktoporweb), its mode and its version. A request no block matches is refused with5001, so give every configuration a last block for every platform, mode and version. The strings reach the app only from a block that declareslanguagesSupported.
The quickstart creates all three, and its last step is the same call the SDK makes.
The periodic check
Whether the SDK also checks at intervals while the app stays in the foreground, and how often, is decided by the configuration, not by the app: it is the refreshInterval of the API block Squiddy resolves for the app, in seconds, which reaches the SDK as refreshIntervalSeconds in serverApi. Whoever manages the configuration sets it, changes it or turns it off without a new version of the app, and since it sits in the API block it can differ by platform, mode and version, with the matching rules the configuration already has: for example no periodic check for the mobile apps, which receive the push update, and one every 5 minutes for a web page, which cannot.
"api": [
{ "appTypes": ["web"], "refreshInterval": 300, "...": "..." },
{ "appTypes": ["ios", "android"], "...": "..." }
]
refreshInterval of the API block | What the SDK does in the foreground |
|---|---|
absent, or 0 | No periodic check: the default, and the case of every configuration written before the field existed |
30 to 86400 | One check every that many seconds: 300 is 5 minutes, 86400 a day |
| anything else | Squiddy refuses to publish it |
- Never in the background: no timer runs there, and a check that falls due waits for the app to come back.
- Kept with the configuration: the device stores the frequency with the configuration it came with, so it holds after a restart and after a
not_modifiedanswer. A configuration received with another frequency reschedules the next check, and one received without it, or with0, stops the periodic check. - Before any configuration has been received there is no periodic check: a failing first call is retried with the backoff of working offline.
- Off by default: an app that receives no push update and whose API block has no
refreshIntervalsees a new configuration only at its next start or its next return to the foreground. If it must notice one while it stays open, its block needs the field. - On the JVM, which has no foreground to return to, an application whose block has no
refreshIntervalsees a new configuration only at its next start, onrefresh(), onhandlePushor on a change of language withsetLanguage. A change of the system's language reaches it at its next check.
The calls against the key's limit. Every installation of an app calls with the same key, and Squiddy limits the calls a key may make in a minute, according to the plan. An installation in the foreground makes one call per refreshInterval, so the calls a minute the key needs are the installations open at the same moment divided by the interval in minutes: 10,000 installations open at once make 2,000 calls a minute with 300, and 20,000 with 30, the shortest. The checks at start-up, on a return to the foreground and on a push update come on top. A key over its limit is answered 429, which the SDK honours (see errors): its installations keep the configuration they have until their next attempt. A configuration with more installations than its key's plan holds uses a longer refreshInterval, none at all with the push update, or a key per group of installations.
Up to 0.2.0 the interval was an option of the app, refreshInterval, 5 minutes by default. From 0.3.0 the option is gone: an app that sets it no longer compiles until the line is deleted, and the changelog says what to do on each platform.
The API key in an app is not a secret
An app that reads Squiddy carries its data-plane key inside: in the APK, in the iOS binary, in the JAR, in the JavaScript every visitor of a page downloads. Anyone who has the app can take the key out of it, so treat it as public, as the Firebase and Maps keys of the same app are. What the key allows is narrow:
- reading the published configuration of the apps of its environment, and nothing else: no draft, no other environment, no change to anything. It is not a dashboard credential: the dashboard and the AdminService take a signed-in person, never a key;
- for any request its holder writes: any
appIdof the environment, any platform, mode, version, language or custom parameter, anyentity_id. So nothing a configuration holds is hidden by a rule: a block for thedebugmode or for one custom parameter is readable by anyone who sends that mode or that parameter, and a percentage rollout chooses who gets a value first, not who may see it. Keep secrets out of configurations: a setting is something every user of the app may read; - spending the key's request budget: Squiddy limits the calls of a key per minute, according to the plan, so a holder who calls in a loop slows down the app's own installations, which then get
429and wait; - subscribing to the app's update notification: the Firebase topic is derived from the key and the
appId. A notification carries no data beyond the request to check; sending one takes the Firebase service account, which only Squiddy holds.
What protects a key is that it can be replaced. In the dashboard, API keys shows when each key was last used; to rotate one, create the new key, ship a version of the app with it, watch the old key's last use stop, and only then revoke it. Revoking a key that installed apps still carry stops their updates: they keep serving what they stored. A key per app, rather than one for the environment, lets you revoke one app's key alone.
Keep the key out of your repository, the same as any credential: the guides inject it into the build from a file git ignores.
Working offline
The SDK keeps one stored configuration per host, key and appId, so two environments or two apps never share one. The key itself never reaches the disk: the file is named by a digest.
| The device | At start-up | Then |
|---|---|---|
| has never received a configuration | Pending while it calls | Ready from the network, or Failed with no configuration |
| holds a configuration | Ready from the cache, before any call | Ready from the network when Squiddy answers, or Failed with the stored configuration |
A failed check never takes the configuration away: Failed carries the error and the last valid configuration, and the app goes on using it. The gate holds for that configuration too, so a maintenance stays shown offline. While there is no configuration at all the gate is None: an app that must not run before it knows waits for the first Ready, and any other app starts with the defaults it ships.
After a failure the SDK retries with an exponential backoff with jitter, from 1 second up to 5 minutes, so the installations of an app do not call back in step after an outage they all saw. A 429 waits for its Retry-After. An Unauthenticated stops the automatic checks until the app calls refresh(): a revoked key does not call forever.
The stored configuration and the installation id are left out of the device's backups (Android's no-backup directory, the iOS directory excluded from iCloud and computer backups, Time Machine on macOS), so a backup restored onto a new device calls Squiddy at its first start. A browser keeps them in the site's localStorage, which clearing the site's data empties, and an Apple TV in the app's caches, which tvOS may empty (tvOS).
The installation id and rollouts
Every request carries an entity_id, the value a percentage rollout places the client by. By default the SDK sends an installation id: a random UUID made at the first start and stored on the device, with no device identifier and no personal data. It stays the same across updates of the app and across the hosts, keys and apps the installation calls, so a rollout does not move it; clearing the app's data or reinstalling makes a new one. On the JVM, on macOS and natively on Linux and Windows there is one per bundle id in the user's data directory of each computer, and in a browser one per origin; an Apple TV makes a new one when tvOS empties its caches.
The entityId option replaces it with an id of yours: an opaque account id, for instance, keeps a user in the same rollout on every device. It is sent exactly as given and never stored, so the app passes it at every start. It must never be an email, a phone number or other personal data.
Errors
A check that fails ends in a SquiddyError, in the Failed state, next to the configuration still served. No other exception leaves the SDK, except the options refused by initialize, which name the option to fix.
| Error | Squiddy's answer | What it means for the app |
|---|---|---|
Unauthenticated | unauthenticated (401) | The key is missing, unknown or revoked. Automatic checks stop until refresh() |
AppNotPublished | 5003, not_found | Nothing is published for the appId in the key's environment: a typo, or the key of another environment |
IncompleteConfiguration | 5001, failed_precondition | The configuration does not resolve for this app: no API block matches it, or a notice has no message row for its language nor a default row. An empty message is not an error: it arrives empty |
InvalidRequest | 5002, invalid_argument | A required field is missing or malformed. The SDK checks the options when it starts, so this one is rare |
TenantSuspended | 5004, permission_denied | The account is not being served. Keep using the stored configuration, and tell a person |
RateLimited | resource_exhausted (429) | The key is over its calls a minute. retryAfter says when the SDK calls again |
ServerError | 5000, internal, or any other answer | Squiddy failed: the SDK retries with its backoff |
Network | no answer | No network, an unknown host, a refused connection or a TLS failure |
Timeout | no answer in time | The call ran out of its timeout, 10 seconds by default |
MalformedResponse | an unreadable answer | Something that is not Squiddy answered, such as a proxy's error page |
The ConfigService reference has every field and error of the call itself.
macOS, tvOS and visionOS
Mac apps and Apple TV apps take the Swift package of iOS, which declares macOS and tvOS from 0.8.0, with the same Swift API: the SDK on macOS and the SDK on tvOS, visionOS and watchOS say what is different there. A Mac app declares desktop, as a desktop application on the JVM; an Apple TV app declares tvos, so its configuration needs a block for it. An app for Apple Vision Pro runs the iOS package as an iPad app. watchOS is not supported yet.
Kotlin Multiplatform
A Kotlin Multiplatform project adds cloud.squiddy:squiddy to its common code and reads the configuration with the same Kotlin API on every target: Android, the JVM, iOS, macOS, tvOS, Linux and Windows natively, and the browser with Kotlin/JS or Kotlin/Wasm. The SDK in Kotlin Multiplatform has every target with its entry point, its files and the app type it sends, and what a Linux program needs from its system.
Web
Web apps use the npm package, @squiddy-cloud/sdk, in the browser and in Node.js: the SDK on the web is its guide, from the installation to the errors, with what is different in a page (the CORS of the data plane, localStorage, no push update), in Node.js (the bundle id, a storage directory, no background) and in server rendering, where a Next.js or Remix server reads the configuration and the page arrives with it.
A web app written in Kotlin, compiled to JavaScript or to WebAssembly (Compose for Web), takes the Kotlin API from Maven Central instead: Kotlin Multiplatform.
A page that would rather not add a package makes the SDK's call itself: the fetch of the TypeScript example runs in a browser as it is, with the host, the key and the appId given by the page instead of the environment, and web as the appType. It gets the CORS answers the SDK gets, and none of what the SDK adds: no stored configuration, no conditional requests, no checks while the page is open.
Flutter
Flutter apps use the plugin squiddy_flutter, from pub.dev, on Android, iOS and the web: the SDK in Flutter is its guide. It is a bridge to the SDK of each platform, of the plugin's own version, and adds no logic of its own, so a Flutter app reads its configuration as a native app or a page does; on the web the page loads the npm package through an import map, and has no push update.
React Native
React Native apps use the module @squiddy-cloud/react-native, from npm, on Android and iOS: the SDK in React Native is its guide. It is a bridge to the SDK of each platform, of the module's own version, with the API of the npm package plus the push update, and adds no logic of its own; on iOS it installs with CocoaPods, from the podspec its package carries with the SDK, or with Swift Package Manager. The React hooks, @squiddy-cloud/react, read its values in components, as they read the npm package's in a page (React).
.NET
.NET apps use the package Squiddy, from nuget.org, with one C# API on the desktops (Windows, Linux and macOS: WinUI, WPF, Windows Forms, console) and in .NET MAUI on Android and iOS: the SDK in .NET is its guide. It is a bridge to the SDK of each system, of the package's own version, which the package carries: the SDK's C library on the desktops and on iOS, its Android library on Android. A desktop app declares desktop, as on the JVM, and a MAUI app android or ios.