diff --git a/GettingStarted.md b/GettingStarted.md index 69f7aa6a1..ed68b0727 100644 --- a/GettingStarted.md +++ b/GettingStarted.md @@ -19,27 +19,23 @@ The **Red App** is a SwiftUI sample application that exercises every major featu ### Option A — Open via the workspace (recommended) +

+ Xcode scheme selector showing OneSignalSwiftUIExample +

+ 1. Open `iOS_SDK/OneSignalSDK.xcworkspace` in Xcode. 2. In the scheme selector (top-left toolbar), choose **OneSignalSwiftUIExample**. 3. Pick a simulator (e.g. iPhone 17 Pro) or a connected device. 4. Press **Cmd + R** to build and run. -Your Xcode toolbar should look like this — scheme set to **OneSignalSwiftUIExample**, a simulator chosen, and the app running: - -

- Xcode toolbar showing the app running -

- -The workspace contains multiple schemes. Make sure **OneSignalSwiftUIExample** is selected: +Your Xcode toolbar should look like this above — scheme set to **OneSignalSwiftUIExample**, a simulator or physical device chosen, and the app running. -

- Xcode scheme selector showing OneSignalSwiftUIExample -

+The workspace contains multiple schemes. Make sure **OneSignalSwiftUIExample** is selected. Once the app is running, SDK debug logs stream to the Xcode console — useful for verifying network calls, subscription state, and in-app message events:

- Xcode console showing SDK debug logs + Xcode console showing SDK debug logs

### Option B — Open from the terminal @@ -66,8 +62,11 @@ Select the **OneSignalSwiftUIExample** scheme, pick a destination, and run. The default App ID (`77e32082-ea27-...c72e141824ef`) is a shared test key. To use your own: +**Changing the App ID requires uninstalling and reinstalling the app for it to take effect.** + 1. Open `iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Services/OneSignalService.swift`. 2. Replace the `defaultAppId` value with your OneSignal App ID (available at [onesignal.com](https://onesignal.com)). +3. Then uninstall the app from the device/simulator and run it again. ## Features diff --git a/docs/assets/xcode-run-button.png b/docs/assets/xcode-run-button.png deleted file mode 100644 index 5ade7c510..000000000 Binary files a/docs/assets/xcode-run-button.png and /dev/null differ diff --git a/docs/assets/xcode-scheme-selector.png b/docs/assets/xcode-scheme-selector.png index f4c75234b..e3ecb2608 100644 Binary files a/docs/assets/xcode-scheme-selector.png and b/docs/assets/xcode-scheme-selector.png differ diff --git a/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/App/OneSignalSwiftUIExampleApp.swift b/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/App/OneSignalSwiftUIExampleApp.swift index ab6875512..fe39a3a77 100644 --- a/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/App/OneSignalSwiftUIExampleApp.swift +++ b/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/App/OneSignalSwiftUIExampleApp.swift @@ -144,7 +144,9 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele private func restoreCachedStates() { // Restore IAM paused status - let iamPaused = UserDefaults.standard.bool(forKey: cachedIAMPausedKey) + let iamPaused = UserDefaults.standard.object(forKey: cachedIAMPausedKey) == nil + ? true + : UserDefaults.standard.bool(forKey: cachedIAMPausedKey) OneSignal.InAppMessages.paused = iamPaused // Restore location shared status diff --git a/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/ViewModels/OneSignalViewModel.swift b/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/ViewModels/OneSignalViewModel.swift index 50e0f1bad..b7d4a0624 100644 --- a/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/ViewModels/OneSignalViewModel.swift +++ b/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/ViewModels/OneSignalViewModel.swift @@ -621,7 +621,7 @@ private class Observers: NSObject, OSPushSubscriptionObserver, OSUserStateObserv func onNotificationPermissionDidChange(_ permission: Bool) { Task { @MainActor in viewModel?.notificationPermissionGranted = permission - viewModel?.isPushEnabled = permission && (viewModel?.isPushEnabled ?? false) + viewModel?.isPushEnabled = OneSignal.User.pushSubscription.optedIn } } } diff --git a/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Views/Components/NotificationGrid.swift b/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Views/Components/NotificationGrid.swift index 1545313c5..8059af4f0 100644 --- a/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Views/Components/NotificationGrid.swift +++ b/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Views/Components/NotificationGrid.swift @@ -33,12 +33,14 @@ struct SendPushButtons: View { let onSimple: () -> Void let onWithImage: () -> Void let onCustom: () -> Void + let onClearAll: () -> Void var body: some View { VStack(spacing: 8) { ActionButton(title: "Simple", action: onSimple) ActionButton(title: "With Image", action: onWithImage) ActionButton(title: "Custom", action: onCustom) + ActionButton(title: "Clear All", action: onClearAll) } } } @@ -70,7 +72,8 @@ struct SendInAppButtons: View { SendPushButtons( onSimple: { print("Simple") }, onWithImage: { print("With Image") }, - onCustom: { print("Custom") } + onCustom: { print("Custom") }, + onClearAll: { print("Clear All") } ) Text("Send In-App Message") diff --git a/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Views/Sections/NotificationSection.swift b/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Views/Sections/NotificationSection.swift index 444f77ac2..0d15d5785 100644 --- a/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Views/Sections/NotificationSection.swift +++ b/iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Views/Sections/NotificationSection.swift @@ -44,6 +44,9 @@ struct SendPushSection: View { }, onCustom: { viewModel.showingCustomNotificationSheet = true + }, + onClearAll: { + viewModel.clearAllNotifications() } ) }