Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,23 @@ The **Red App** is a SwiftUI sample application that exercises every major featu

### Option A — Open via the workspace (recommended)

<p align="center">
<img src="docs/assets/xcode-scheme-selector.png" alt="Xcode scheme selector showing OneSignalSwiftUIExample" style="width:90%;max-width:100%"/>
</p>

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:

<p align="center">
<img src="docs/assets/xcode-run-button.png" alt="Xcode toolbar showing the app running" width="700"/>
</p>

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.

<p align="center">
<img src="docs/assets/xcode-scheme-selector.png" alt="Xcode scheme selector showing OneSignalSwiftUIExample" width="700"/>
</p>
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:

<p align="center">
<img src="docs/assets/xcode-console-output.png" alt="Xcode console showing SDK debug logs" width="700"/>
<img src="docs/assets/xcode-console-output.png" alt="Xcode console showing SDK debug logs" style="width:90%;max-width:100%"/>
</p>

### Option B — Open from the terminal
Expand All @@ -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

Expand Down
Binary file removed docs/assets/xcode-run-button.png
Binary file not shown.
Binary file modified docs/assets/xcode-scheme-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ struct SendPushSection: View {
},
onCustom: {
viewModel.showingCustomNotificationSheet = true
},
onClearAll: {
viewModel.clearAllNotifications()
}
)
}
Expand Down
Loading