Skip to content

Commit 23516e4

Browse files
chore: [SDK-4716] revamp iOS examples/demo for cross-SDK parity (#1663)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent fca0943 commit 23516e4

162 files changed

Lines changed: 6615 additions & 9309 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ DerivedData
1818
.idea/
1919
iOS_SDK/Carthage/Build
2020
/temp/
21-
.build/
21+
.build/
22+
23+
examples/demo/App/Secrets.plist
24+
examples/demo/Local.xcconfig

GettingStarted.md

Lines changed: 27 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# Getting Started with the Red App
1+
# Getting Started
22

3-
The **Red App** is a SwiftUI sample application that exercises every major feature of the OneSignal iOS SDK. Use it to validate SDK behavior, test integrations, and explore the API surface on a simulator or physical device.
3+
This repo ships two ways to exercise the OneSignal iOS SDK:
44

5-
<p align="center">
6-
<img src="docs/assets/red-app-screenshot.png" alt="Red App screenshot" width="300"/>
7-
</p>
5+
| App | Location | Purpose |
6+
|-----|----------|---------|
7+
| **OneSignalDevApp** | `iOS_SDK/OneSignalDevApp/` | Internal dev/test app wired into `OneSignalSDK.xcworkspace`. Builds against **local SDK source**, so any changes you make to the SDK are picked up immediately. Use this when modifying the SDK. |
8+
| **examples/demo** | `examples/demo/` | Customer-facing SwiftUI demo that mirrors the OneSignal Capacitor / Cordova / RN demos (same section layout, accessibility identifiers, sdk-shared tooltip content). Builds against the published SwiftPM SDK. Use this as a reference integration. |
89

910
## Prerequisites
1011

@@ -15,86 +16,42 @@ The **Red App** is a SwiftUI sample application that exercises every major featu
1516
| Swift | 5.9+ |
1617
| iOS target | 16.0+ |
1718

18-
## Running the App
19+
## Running OneSignalDevApp (SDK contributors)
1920

20-
### Option A — Open via the workspace (recommended)
21+
This is the recommended path when you're working on the SDK itself.
2122

22-
<p align="center">
23-
<img src="docs/assets/xcode-scheme-selector.png" alt="Xcode scheme selector showing OneSignalSwiftUIExample" style="width:90%;max-width:100%"/>
24-
</p>
25-
26-
1. Open `iOS_SDK/OneSignalSDK.xcworkspace` in Xcode.
27-
2. In the scheme selector (top-left toolbar), choose **OneSignalSwiftUIExample**.
28-
3. Pick a simulator (e.g. iPhone 17 Pro) or a connected device.
23+
1. Open `iOS_SDK/OneSignalSDK.xcworkspace` in Xcode (the workspace, not any individual `.xcodeproj`).
24+
2. Select the **OneSignalDevApp** scheme.
25+
3. Pick a simulator or a connected device.
2926
4. Press **Cmd + R** to build and run.
3027

31-
Your Xcode toolbar should look like this above — scheme set to **OneSignalSwiftUIExample**, a simulator or physical device chosen, and the app running.
32-
33-
The workspace contains multiple schemes. Make sure **OneSignalSwiftUIExample** is selected.
34-
35-
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:
36-
37-
<p align="center">
38-
<img src="docs/assets/xcode-console-output.png" alt="Xcode console showing SDK debug logs" style="width:90%;max-width:100%"/>
39-
</p>
40-
41-
### Option B — Open from the terminal
42-
43-
```bash
44-
open iOS_SDK/OneSignalSDK.xcworkspace
45-
```
46-
47-
Then follow steps 2–4 from Option A.
48-
49-
### Option C — Open only the example project
50-
51-
> Use this if you only need the sample app and don't plan to modify the SDK source.
52-
53-
```bash
54-
open iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample.xcodeproj
55-
```
28+
SDK debug logs stream to the Xcode console — useful for verifying network calls, subscription state, and in-app message events.
5629

57-
Select the **OneSignalSwiftUIExample** scheme, pick a destination, and run.
30+
> Push notification delivery requires a **physical device** with a valid APNs configuration. The simulator supports permission prompts and token generation but won't receive remote pushes.
5831
59-
> **Note:** Opening the `.xcworkspace` (Options A/B) is preferred because it links the sample app against the SDK source, so any local SDK changes are picked up automatically.
32+
## Running examples/demo (reference integration)
6033

61-
## Using Your Own App ID
34+
The `examples/demo/` app demonstrates the recommended integration shape for app developers, including a Notification Service Extension target and a Live Activities Widget Extension target.
6235

63-
The default App ID (`77e32082-ea27-...c72e141824ef`) is a shared test key. To use your own:
36+
See [`examples/demo/README.md`](examples/demo/README.md) for full setup steps. In short:
6437

65-
**Changing the App ID requires uninstalling and reinstalling the app for it to take effect.**
38+
1. Create the Xcode project at `examples/demo/App.xcodeproj` (the source files and extension folders are checked in but `project.pbxproj` is not).
39+
2. Add the OneSignal SwiftPM dependency (`https://github.com/OneSignal/OneSignal-iOS-SDK`, 5.0.0+) and attach the right products to each of the three targets (App / NSE / Widget).
40+
3. Configure capabilities (Push Notifications, App Groups, Background Modes → Remote notifications) and run.
6641

67-
1. Open `iOS_SDK/OneSignalSwiftUIExample/OneSignalSwiftUIExample/Services/OneSignalService.swift`.
68-
2. Replace the `defaultAppId` value with your OneSignal App ID (available at [onesignal.com](https://onesignal.com)).
69-
3. Then uninstall the app from the device/simulator and run it again.
42+
## Using your own App ID
7043

71-
## Features
44+
Both apps default to a shared OneSignal App ID. To switch to your own:
7245

73-
The Red App is organized into scrollable sections, each mapping to a OneSignal SDK capability:
46+
- **OneSignalDevApp** — open `iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m` and replace the App ID passed to `OneSignal.initialize`.
47+
- **examples/demo** — edit `examples/demo/App/Services/OneSignalService.swift` and replace `defaultAppId`, or override at runtime via `UserDefaults` (key `OneSignalAppId`).
7448

75-
| Section | What It Does |
76-
|---------|-------------|
77-
| **Logs** | Collapsible live SDK log viewer with a configurable entry limit and clear button. |
78-
| **App Info** | Displays the current App ID and a consent-required toggle that gates SDK data processing. |
79-
| **User** | Shows login status (Anonymous / Identified) and External ID. Login and logout buttons to switch between user states. |
80-
| **Push** | Displays the Push Subscription ID, an enable/disable toggle, and permission status. |
81-
| **Send Push Notification** | Quick-fire buttons (Simple, Custom) to send test push notifications to the current device. |
82-
| **In-App Messaging** | Pause/resume in-app messages. |
83-
| **Send In-App Message** | Trigger a test in-app message. |
84-
| **Aliases** | Add and remove key-value aliases for the current user. |
85-
| **Email** | Add and remove email subscriptions. |
86-
| **SMS** | Add and remove SMS subscriptions. |
87-
| **Tags** | Manage user tags used for audience segmentation. |
88-
| **Outcome Events** | Fire unique, regular, or valued outcome events for analytics. |
89-
| **Triggers** | Set and remove in-app message triggers. |
90-
| **Track Event** | Send custom user events with optional properties. |
91-
| **Location** | Toggle location sharing and request location permissions. |
92-
| **Live Activities** | Start and manage iOS Live Activities via OneSignal. |
49+
Changing the App ID requires uninstalling and reinstalling the app for it to take effect.
9350

9451
## Troubleshooting
9552

9653
| Problem | Fix |
9754
|---------|-----|
98-
| Build fails with missing framework | Make sure you opened the **`.xcworkspace`**, not the `.xcodeproj`. |
99-
| Push notifications don't arrive on simulator | Push delivery requires a **physical device** with a valid APNs configuration. The simulator supports permission prompts and token generation but won't receive remote pushes. |
100-
| "Consent Required" blocks SDK calls | Toggle **Consent Required** off, or call the consent API to grant consent. |
55+
| Build fails with missing framework | Open the workspace (`OneSignalSDK.xcworkspace`), not an individual `.xcodeproj`. |
56+
| Push notifications don't arrive on simulator | Push delivery requires a physical device with APNs configured. |
57+
| "Consent Required" blocks SDK calls | Toggle **Consent Required** off, or grant consent via the SDK's consent API. |

OneSignalSwiftUIExample/OneSignalSwiftUIExample.entitlements

Lines changed: 0 additions & 8 deletions
This file was deleted.

OneSignalSwiftUIExample/OneSignalSwiftUIExample/Models/AppModels.swift

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)