You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/build.md
+17-18Lines changed: 17 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,10 +170,6 @@ All OneSignal SDK interactions and state are managed through a single `useOneSig
170
170
171
171
`HomeScreen` calls `useOneSignal()` and passes state/callbacks down to section components as props.
172
172
173
-
### Repository Pattern
174
-
175
-
`OneSignalRepository` (`src/repositories/OneSignalRepository.ts`) wraps all OneSignal SDK calls with `Capacitor.isNativePlatform()` guards, providing a safe abstraction that no-ops on web. It also delegates notification sending and user fetching to `OneSignalApiService`.
176
-
177
173
### Services
178
174
179
175
-`OneSignalApiService` (`src/services/OneSignalApiService.ts`) — Singleton REST client using `fetch` to send notifications via the OneSignal API and fetch user data
@@ -338,7 +334,7 @@ Under the hood, `addEventListener` wraps Capacitor's `this._plugin.addListener(n
338
334
The `useOneSignal()` hook centralizes all SDK state and actions:
339
335
340
336
-**Reactive state** via `useState`: app ID, consent settings, external user ID, push subscription ID, push enabled, notification permission, IAM paused, location shared, aliases, emails, SMS numbers, tags, triggers, loading state
341
-
-**Refs** via `useRef`: mount tracking (`mountedRef`), request sequencing (`requestSequenceRef`) to discard stale API responses
337
+
-**Refs** via `useRef`: request sequencing (`requestSequenceRef`) to discard stale API responses
342
338
-**Effects** via `useEffect`: one-time SDK init + listener registration with full cleanup
343
339
-**Memoized callbacks** via `useCallback`: `fetchUserDataFromApi` for API-driven state refresh
344
340
@@ -494,19 +490,17 @@ The iOS Xcode project includes extension targets:
494
490
-`ios/App/OneSignalNotificationServiceExtension/NotificationService.swift` — forwards to `OneSignalExtension` for rich notification support
495
491
-`ios/App/OneSignalNotificationServiceExtension/Info.plist` — extension point `com.apple.usernotifications.service`
496
492
497
-
### Podfile
493
+
### Swift Package Manager
498
494
499
-
The Podfile includes the NSE target:
495
+
The demo uses Swift Package Manager (SPM) instead of CocoaPods. Capacitor manages the App target's plugin dependencies through `ios/App/CapApp-SPM/Package.swift`. The extension targets reference the OneSignal XCFramework Swift package directly:
500
496
501
-
```ruby
502
-
target 'App'do
503
-
capacitor_pods
504
-
end
497
+
- App target → `CapApp-SPM` local package (Capacitor + plugin products, regenerated by `cap sync`)
498
+
-`OneSignalNotificationServiceExtension` → `OneSignalExtension` product from `https://github.com/OneSignal/OneSignal-XCFramework`
499
+
-`OneSignalWidgetExtension` → `OneSignalFramework` product from `https://github.com/OneSignal/OneSignal-XCFramework` (transitively brings in `OneSignalLiveActivities` for Live Activity widgets)
505
500
506
-
target 'OneSignalNotificationServiceExtension'do
507
-
pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0'
508
-
end
509
-
```
501
+
`ios/debug.xcconfig` is wired up as the App target's Debug base configuration so Capacitor's debug-only behaviors stay enabled.
502
+
503
+
To migrate an existing CocoaPods-based project to SPM, run `bunx cap spm-migration-assistant` and then add the local `CapApp-SPM` package and any extension dependencies through Xcode's Package Dependencies tab.
510
504
511
505
---
512
506
@@ -525,7 +519,7 @@ end
525
519
-`handleApplicationNotifications: false` in `capacitor.config.ts` to let OneSignal handle notifications
526
520
- Capacitor setup with push notification entitlement and app groups
527
521
- NSE target in Xcode project
528
-
-Podspec named `OnesignalCapacitorPlugin` to match Capacitor's derived pod name (Capacitor's `fixName` converts `onesignal-capacitor-plugin` → `OnesignalCapacitorPlugin`)
522
+
-SPM product named `OnesignalCapacitorPlugin` to match Capacitor's derived package name (Capacitor's `fixName` converts `onesignal-capacitor-plugin` → `OnesignalCapacitorPlugin`)
0 commit comments