feat: [SDK-4324] add Capacitor SPM example demo project - #4
Merged
Conversation
sherwinski
approved these changes
Apr 23, 2026
Comment on lines
+1
to
+3
| VITE_ONESIGNAL_APP_ID=your_onesignal_app_id | ||
| VITE_ONESIGNAL_API_KEY=your_rest_api_key | ||
| VITE_E2E_MODE=false No newline at end of file |
Contributor
Author
There was a problem hiding this comment.
Its for e2e and local testing
Comment on lines
+252
to
+262
| OneSignal.InAppMessages.addEventListener('willDisplay', handleIamWillDisplay); | ||
| OneSignal.InAppMessages.addEventListener('didDisplay', handleIamDidDisplay); | ||
| OneSignal.InAppMessages.addEventListener('willDismiss', handleIamWillDismiss); | ||
| OneSignal.InAppMessages.addEventListener('didDismiss', handleIamDidDismiss); | ||
| OneSignal.InAppMessages.addEventListener('click', handleIamClick); | ||
| OneSignal.Notifications.addEventListener('click', handleNotificationClick); | ||
| OneSignal.Notifications.addEventListener('permissionChange', permissionHandler); | ||
| OneSignal.Notifications.addEventListener( | ||
| 'foregroundWillDisplay', | ||
| handleForegroundWillDisplay, | ||
| ); |
There was a problem hiding this comment.
Nit: should event listeners be added before initialize? If something like permissions are changed before init completes, it might get missed
Contributor
Author
There was a problem hiding this comment.
I think initialize always has to be called first.
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
Add a new Capacitor + React example demo at
examples/demo/that uses Swift Package Manager on iOS, plus Package.swift fixes to align the plugin's SPM product name with Capacitor's derived name and switch to the officialOneSignal/OneSignal-XCFrameworkpackage.Details
Motivation
The repo only had a CocoaPods-based example (
examples/demo_pods/). With Capacitor 7's first-class SPM support and the upcoming default switch to SPM, we need a maintained SPM-based reference app for testing and onboarding. While building the new demo I also hit two SDK-side issues that this PR fixes:Package.swiftdeclared the library asOneSignalCapacitorPlugin, but Capacitor'sfixNamerewritesonesignal-capacitor-plugintoOnesignalCapacitorPlugin, so SPM-based apps couldn't resolve the plugin product. Renamed both the package and the target toOnesignalCapacitorPlugin.nicklama/onesignal-xcframework-spm). Switched to the officialOneSignal/OneSignal-XCFrameworkrepo and widened thecapacitor-swift-pmrange to7.0.0..<9.0.0.Scope
examples/demo/(new SPM-based Capacitor + React + Ionic app) with iOS, Android, NSE, and Live Activity widget targets.examples/build.mdwith the new build/setup instructions for the SPM demo.Package.swift(product/target rename + dependency source) — required for any SPM consumer of the plugin, including the new demo.examples/demo_pods/UI to share the same component patterns anduseOneSignalhook shape as the new demo, and addsdata-testidattributes for Appium. Behavior ofdemo_podsis otherwise unchanged.src/orios/Sources/OneSignalCapacitorPlugin/source files (only the Swift package manifest changed).Testing
Manual testing
examples/demo/on iOS via SPM (bunx cap sync ios, opened in Xcode 16, ran on iPhone 16 simulator and a physical iPhone). Verified push registration, foreground/background notification click, IAM display + click, login/logout, alias/email/SMS/tag add+remove, outcomes, triggers, custom event, location permission, and Live Activity start/exit.examples/demo/on Android viabunx cap sync androidandbunx cap run androidagainst a Pixel 7 emulator (API 34). Verified push registration, notification click, and IAM flows.examples/demo_pods/on iOS and Android to confirm the UI refactor still works against the same SDK build.bun run build+bun packproduce a tarball that installs cleanly into the new demo via thesetup.shflow.Affected code checklist
OneSignalCapacitorPlugin→OnesignalCapacitorPlugin. Capacitor consumers don't import the product directly, but anyone pinning the SPM product name in a customPackage.swiftwill need to update.)Checklist
Overview
Testing
Final pass
Made with Cursor