From 10e3b54d0ca387c62785ee94f862ce0bc75e2446 Mon Sep 17 00:00:00 2001 From: FuelBoard Contributor Date: Thu, 20 Aug 2026 12:27:09 +0100 Subject: [PATCH] onboarding: persist completed flag keychain-first so it doesn't re-show The completed flag lived only in app-group UserDefaults (UserDefaults(suiteName: appGroupSuite)). On free SideStore accounts the app-group container isn't provisioned, so the suite read as nil: save was a silent no-op and load always returned false -> onboarding re-appeared on every launch even after finishing and granting all permissions. Switch to saveString/loadString (keychain-first, app-group mirror) under onboardingCompletedKey, matching favourites/distance-unit persistence which survives reinstall and works without a provisioning group. loadString falls back to the app-group mirror, so anyone who previously completed on a provisioned group keeps their flag; users on unprovisioned groups complete once more and then it sticks. --- Shared/FuelStore.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Shared/FuelStore.swift b/Shared/FuelStore.swift index 6b51ed5..6c0cc94 100644 --- a/Shared/FuelStore.swift +++ b/Shared/FuelStore.swift @@ -934,15 +934,19 @@ struct FuelStore { } // MARK: Onboarding — the app shows the intro screen on first launch only - // (a test button in the Alerts tab re-opens it). Stored in the app group - // so the widget can see it too if ever needed. + // (a test button in the Alerts tab re-opens it). Stored KEYCHAIN-FIRST + // (with an app-group mirror) for the same reason as favourites/distance + // unit: free SideStore accounts don't provision the app-group container, + // so an app-group-only flag silently fails to save AND reloads as false, + // making onboarding re-appear on every launch. Keychain survives reinstall + // and is shared with the extension. static func loadHasCompletedOnboarding() -> Bool { - UserDefaults(suiteName: appGroupSuite)?.bool(forKey: onboardingCompletedKey) ?? false + (loadString(service: onboardingCompletedKey) ?? "0") == "1" } static func saveHasCompletedOnboarding(_ completed: Bool) { - UserDefaults(suiteName: appGroupSuite)?.set(completed, forKey: onboardingCompletedKey) + saveString(completed ? "1" : "0", service: onboardingCompletedKey) } // MARK: Low-level keychain helpers