chore: [SDK-4716] revamp iOS examples/demo for cross-SDK parity#1663
Merged
Conversation
Per sdk-shared/demo/build.md Prompt 7.6, snackbar/toast state must live in the UI layer, not in the state management layer. - New ToastPresenter (@mainactor ObservableObject) injected via @EnvironmentObject, with a named toastDurationMs constant - OneSignalViewModel drops toastMessage / showToast / dismiss task - OutcomesSection, CustomEventsSection, LocationSection call toast.show(...) after the SDK action instead of routing through the ViewModel - checkLocationShared() returns Bool so the section formats the message rather than the ViewModel Co-authored-by: Cursor <cursoragent@cursor.com>
sherwinski
reviewed
May 26, 2026
- Guard fetchUserDataFromApi with a requestSequence counter so a slow fetch for an earlier onesignal_id can't overwrite results from a later fetch (logout -> login race). - Drop the redundant CachedConsentRequired / CachedPrivacyConsent UserDefaults caching in the view model; OneSignalService is the single source of truth. - Remove the unused 100ms Task.sleep at the tail of fetchUserDataFromApi. - Update UIRequiredDeviceCapabilities from armv7 to arm64. Co-authored-by: Cursor <cursoragent@cursor.com>
Mirror the Capacitor useOneSignal hook's preference flow so the demo restores user state on cold launch instead of resetting to defaults. - Introduce PreferencesService (UserDefaults-backed) as the single source of truth for consent, IAM-paused, location-shared, and the last-logged-in external user id, keyed under onesignal.demo.*. - OneSignalService.initialize now feeds cached consent into the SDK before OneSignal.initialize, then restores IAM-paused, location-shared, and re-logs the stored external user id once the SDK is ready. - Setters on OneSignalService write through PreferencesService and forward to the SDK, so the view model can hydrate @published state from the service and get cached values for free. - Seed externalUserId in the view model from prefs as a fallback so the UI shows the right id immediately on launch even before the SDK's user-state observer fires. Co-authored-by: Cursor <cursoragent@cursor.com>
sherwinski
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Rework
examples/demoto match the sharedsdk-shared/demospec and reach feature and structure parity with the Capacitor demo.Appium Tests:
Details
Motivation
The iOS demo was a simple SwiftUI sample that diverged from the cross-SDK demo spec. The shared spec standardizes sections, accessibility identifiers, credential handling, and UI styling so a single Appium suite can target every platform. This PR brings the iOS demo to that standard and unblocks shared E2E coverage.
Scope
examples/demo. No SDK source changes.iOS_SDK/OneSignalSwiftUIExampleapp, both removed.OneSignalNotificationServiceExtensionandOneSignalWidget(Live Activities) targets.Theme.swift, centered tooltip dialogs, snake_case accessibility ids, app-bar logo with iOS text, a white launch screen, and the official app icon.Secrets.plistviaSecretsConfig.Local.xcconfig(referenced byBuild.xcconfig) soxcodegen generateno longer wipes team ids.com.onesignal.example, NSEcom.onesignal.example.NSE, widgetcom.onesignal.example.LA.Other
The Xcode project is generated from
examples/demo/project.ymlviaxcodegen. The committedApp.xcodeproj/project.pbxprojis regenerable.Build.xcconfigdoes an optional include ofLocal.xcconfigso per-developer overrides survive regeneration without leaking into the repo.Testing
Manual testing
Built and ran the App scheme on the iPhone 17 simulator via
iOS_SDK/OneSignalSDK.xcworkspace. Verified:sdk-shared/demo/build.mdandstyles.md.Secrets.plistis read at startup. Missing app id falls back to the placeholder; missing API key disables Live Activity update and end with the expected hint.xcodegen generateand confirmedDEVELOPMENT_TEAMfromLocal.xcconfigis preserved in the regeneratedproject.pbxproj.Affected code checklist
None of the SDK code paths below were touched. All changes are confined to
examples/demo.Checklist
Overview
Testing
Final pass
Made with Cursor