diff --git a/Package.swift b/Package.swift index 12d19a4..9df2910 100644 --- a/Package.swift +++ b/Package.swift @@ -3,25 +3,25 @@ import PackageDescription let package = Package( - name: "OneSignalCapacitorPlugin", + name: "OnesignalCapacitorPlugin", platforms: [.iOS(.v14)], products: [ .library( - name: "OneSignalCapacitorPlugin", - targets: ["OneSignalCapacitorPlugin"] + name: "OnesignalCapacitorPlugin", + targets: ["OnesignalCapacitorPlugin"] ) ], dependencies: [ - .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0"), - .package(url: "https://github.com/nicklama/onesignal-xcframework-spm", from: "5.0.0") + .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", "7.0.0"..<"9.0.0"), + .package(url: "https://github.com/OneSignal/OneSignal-XCFramework", from: "5.0.0") ], targets: [ .target( - name: "OneSignalCapacitorPlugin", + name: "OnesignalCapacitorPlugin", dependencies: [ .product(name: "Capacitor", package: "capacitor-swift-pm"), .product(name: "Cordova", package: "capacitor-swift-pm"), - .product(name: "OneSignalFramework", package: "onesignal-xcframework-spm") + .product(name: "OneSignalFramework", package: "OneSignal-XCFramework") ], path: "ios/Sources/OneSignalCapacitorPlugin" ) diff --git a/examples/build.md b/examples/build.md index d07667e..5154203 100644 --- a/examples/build.md +++ b/examples/build.md @@ -170,10 +170,6 @@ All OneSignal SDK interactions and state are managed through a single `useOneSig `HomeScreen` calls `useOneSignal()` and passes state/callbacks down to section components as props. -### Repository Pattern - -`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`. - ### Services - `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 The `useOneSignal()` hook centralizes all SDK state and actions: - **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 -- **Refs** via `useRef`: mount tracking (`mountedRef`), request sequencing (`requestSequenceRef`) to discard stale API responses +- **Refs** via `useRef`: request sequencing (`requestSequenceRef`) to discard stale API responses - **Effects** via `useEffect`: one-time SDK init + listener registration with full cleanup - **Memoized callbacks** via `useCallback`: `fetchUserDataFromApi` for API-driven state refresh @@ -494,19 +490,17 @@ The iOS Xcode project includes extension targets: - `ios/App/OneSignalNotificationServiceExtension/NotificationService.swift` — forwards to `OneSignalExtension` for rich notification support - `ios/App/OneSignalNotificationServiceExtension/Info.plist` — extension point `com.apple.usernotifications.service` -### Podfile +### Swift Package Manager -The Podfile includes the NSE target: +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: -```ruby -target 'App' do - capacitor_pods -end +- App target → `CapApp-SPM` local package (Capacitor + plugin products, regenerated by `cap sync`) +- `OneSignalNotificationServiceExtension` → `OneSignalExtension` product from `https://github.com/OneSignal/OneSignal-XCFramework` +- `OneSignalWidgetExtension` → `OneSignalFramework` product from `https://github.com/OneSignal/OneSignal-XCFramework` (transitively brings in `OneSignalLiveActivities` for Live Activity widgets) -target 'OneSignalNotificationServiceExtension' do - pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0' -end -``` +`ios/debug.xcconfig` is wired up as the App target's Debug base configuration so Capacitor's debug-only behaviors stay enabled. + +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. --- @@ -525,7 +519,7 @@ end - `handleApplicationNotifications: false` in `capacitor.config.ts` to let OneSignal handle notifications - Capacitor setup with push notification entitlement and app groups - NSE target in Xcode project -- Podspec named `OnesignalCapacitorPlugin` to match Capacitor's derived pod name (Capacitor's `fixName` converts `onesignal-capacitor-plugin` → `OnesignalCapacitorPlugin`) +- SPM product named `OnesignalCapacitorPlugin` to match Capacitor's derived package name (Capacitor's `fixName` converts `onesignal-capacitor-plugin` → `OnesignalCapacitorPlugin`) ### Custom Notification Sound @@ -620,7 +614,13 @@ examples/ ├── OneSignalNotificationServiceExtension/ # NSE target │ ├── NotificationService.swift │ └── Info.plist - └── Podfile + ├── OneSignalWidget/ # Widget + Live Activity target + │ ├── OneSignalWidgetBundle.swift + │ ├── OneSignalWidgetLiveActivity.swift + │ └── Info.plist + └── CapApp-SPM/ # Capacitor-managed SPM package + ├── Package.swift # Auto-generated by `cap sync` + └── Sources/CapApp-SPM/CapApp-SPM.swift ``` --- @@ -629,7 +629,6 @@ examples/ - **TypeScript strict mode** on all source files, avoiding `any` and type assertions - **Central `useOneSignal` hook** manages all SDK state and actions; section components are pure props-driven -- **Repository pattern** wraps SDK calls with `Capacitor.isNativePlatform()` guards - **Service layer** separates REST API calls, persistence, and logging from UI - **React + Ionic React** for component-based UI with React Router navigation - **Separate section components** per feature area for maintainability diff --git a/examples/demo/.env.example b/examples/demo/.env.example new file mode 100644 index 0000000..418dea3 --- /dev/null +++ b/examples/demo/.env.example @@ -0,0 +1,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 diff --git a/examples/demo/android/.gitignore b/examples/demo/android/.gitignore new file mode 100644 index 0000000..48354a3 --- /dev/null +++ b/examples/demo/android/.gitignore @@ -0,0 +1,101 @@ +# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore + +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof + +# Cordova plugins for Capacitor +capacitor-cordova-android-plugins + +# Copied web assets +app/src/main/assets/public + +# Generated Config files +app/src/main/assets/capacitor.config.json +app/src/main/assets/capacitor.plugins.json +app/src/main/res/xml/config.xml diff --git a/examples/demo/android/app/.gitignore b/examples/demo/android/app/.gitignore new file mode 100644 index 0000000..043df80 --- /dev/null +++ b/examples/demo/android/app/.gitignore @@ -0,0 +1,2 @@ +/build/* +!/build/.npmkeep diff --git a/examples/demo/android/app/build.gradle.kts b/examples/demo/android/app/build.gradle.kts new file mode 100644 index 0000000..db27ea1 --- /dev/null +++ b/examples/demo/android/app/build.gradle.kts @@ -0,0 +1,56 @@ +plugins { + id("com.android.application") +} + +android { + namespace = "com.onesignal.example" + compileSdk = rootProject.extra["compileSdkVersion"] as Int + defaultConfig { + applicationId = "com.onesignal.example" + minSdk = rootProject.extra["minSdkVersion"] as Int + targetSdk = rootProject.extra["targetSdkVersion"] as Int + versionCode = 1 + versionName = "1.0" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + androidResources { + // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. + // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 + ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~" + } + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } +} + +repositories { + flatDir { + dirs("../capacitor-cordova-android-plugins/src/main/libs", "libs") + } +} + +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.coordinatorlayout) + implementation(libs.androidx.core.splashscreen) + implementation(project(":capacitor-android")) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.junit) + androidTestImplementation(libs.androidx.test.espresso.core) + implementation(project(":capacitor-cordova-android-plugins")) +} + +apply(from = "capacitor.build.gradle") + +try { + val servicesJSON = file("google-services.json") + if (servicesJSON.readText().isNotEmpty()) { + apply(plugin = "com.google.gms.google-services") + } +} catch (e: Exception) { + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") +} diff --git a/examples/demo/android/app/proguard-rules.pro b/examples/demo/android/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/examples/demo/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/examples/demo/android/app/src/main/AndroidManifest.xml b/examples/demo/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0914b39 --- /dev/null +++ b/examples/demo/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo/android/app/src/main/java/com/onesignal/example/MainActivity.java b/examples/demo/android/app/src/main/java/com/onesignal/example/MainActivity.java new file mode 100644 index 0000000..2730476 --- /dev/null +++ b/examples/demo/android/app/src/main/java/com/onesignal/example/MainActivity.java @@ -0,0 +1,76 @@ +package com.onesignal.example; + +import android.os.Bundle; +import android.view.View; +import java.util.Locale; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowCompat; +import androidx.core.view.WindowInsetsCompat; +import com.getcapacitor.BridgeActivity; + +/** + * Edge-to-edge display support for Android 15+ (API 35+). + * + * On Android 15+, edge-to-edge is enforced: the status bar and navigation bar + * are transparent and the app is expected to draw behind them. Capacitor's + * built-in SystemBars plugin applies native padding to keep the WebView below + * the status bar, but this leaves a white gap visible through the transparent + * status bar. + * + * This override: + * 1. Tells the window to let content draw behind system bars. + * 2. Replaces the SystemBars insets listener so the WebView extends behind the + * status bar (top padding = 0). Only bottom padding is applied for the + * on-screen keyboard. + * 3. Injects --ion-safe-area-* CSS variables so the web layer can add its own + * padding (e.g. the red app header) without overlapping the status bar icons. + */ +public class MainActivity extends BridgeActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + } + + @Override + protected void load() { + super.load(); + + float density = getResources().getDisplayMetrics().density; + View webViewParent = (View) bridge.getWebView().getParent(); + + // Override Capacitor's SystemBars insets listener (set during bridge.create()) + // so the WebView draws behind the status bar instead of being pushed below it. + ViewCompat.setOnApplyWindowInsetsListener(webViewParent, (v, insets) -> { + Insets systemBars = insets.getInsets( + WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout() + ); + Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime()); + boolean keyboardVisible = insets.isVisible(WindowInsetsCompat.Type.ime()); + + // No top padding — the CSS header handles the status bar offset. + // Bottom padding only when the keyboard is visible. + v.setPadding(0, 0, 0, keyboardVisible ? imeInsets.bottom : 0); + + // Convert pixel insets to dp and inject as CSS variables. + // WebView < 140 doesn't provide env(safe-area-inset-*) correctly, + // so we set --ion-safe-area-* directly for Ionic to consume. + int top = Math.round(systemBars.top / density); + int right = Math.round(systemBars.right / density); + int bottom = Math.round(systemBars.bottom / density); + int left = Math.round(systemBars.left / density); + String js = String.format(Locale.US, + "document.documentElement.style.setProperty('--ion-safe-area-top','%dpx');" + + "document.documentElement.style.setProperty('--ion-safe-area-right','%dpx');" + + "document.documentElement.style.setProperty('--ion-safe-area-bottom','%dpx');" + + "document.documentElement.style.setProperty('--ion-safe-area-left','%dpx');", + top, right, bottom, left + ); + bridge.getWebView().evaluateJavascript(js, null); + + return insets; + }); + } +} diff --git a/examples/demo/android/app/src/main/res/drawable-land-hdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-land-hdpi/splash.png new file mode 100644 index 0000000..e31573b Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-land-hdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-land-mdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-land-mdpi/splash.png new file mode 100644 index 0000000..f7a6492 Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-land-mdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-land-xhdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-land-xhdpi/splash.png new file mode 100644 index 0000000..8077255 Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-land-xhdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-land-xxhdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-land-xxhdpi/splash.png new file mode 100644 index 0000000..14c6c8f Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-land-xxhdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-land-xxxhdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-land-xxxhdpi/splash.png new file mode 100644 index 0000000..244ca25 Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-land-xxxhdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-port-hdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-port-hdpi/splash.png new file mode 100644 index 0000000..74faaa5 Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-port-hdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-port-mdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-port-mdpi/splash.png new file mode 100644 index 0000000..e944f4a Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-port-mdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-port-xhdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-port-xhdpi/splash.png new file mode 100644 index 0000000..564a82f Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-port-xhdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-port-xxhdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-port-xxhdpi/splash.png new file mode 100644 index 0000000..bfabe68 Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-port-xxhdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable-port-xxxhdpi/splash.png b/examples/demo/android/app/src/main/res/drawable-port-xxxhdpi/splash.png new file mode 100644 index 0000000..6929071 Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable-port-xxxhdpi/splash.png differ diff --git a/examples/demo/android/app/src/main/res/drawable/splash.png b/examples/demo/android/app/src/main/res/drawable/splash.png new file mode 100644 index 0000000..f7a6492 Binary files /dev/null and b/examples/demo/android/app/src/main/res/drawable/splash.png differ diff --git a/examples/demo/android/app/src/main/res/layout/activity_main.xml b/examples/demo/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b5ad138 --- /dev/null +++ b/examples/demo/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/examples/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..0995dbd Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/examples/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..a6383a1 Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-ldpi/ic_launcher.png b/examples/demo/android/app/src/main/res/mipmap-ldpi/ic_launcher.png new file mode 100644 index 0000000..0acfe75 Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-ldpi/ic_launcher.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png b/examples/demo/android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png new file mode 100644 index 0000000..b382217 Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..5f9e3de Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/examples/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..1a2af15 Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..b04f496 Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/examples/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e593d4b Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d0c9f81 Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/examples/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..3528ff1 Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/examples/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..99a1082 Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/examples/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/examples/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..a5d64cf Binary files /dev/null and b/examples/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/examples/demo/android/app/src/main/res/raw/vine_boom.wav b/examples/demo/android/app/src/main/res/raw/vine_boom.wav new file mode 100644 index 0000000..626bd5c Binary files /dev/null and b/examples/demo/android/app/src/main/res/raw/vine_boom.wav differ diff --git a/examples/demo/android/app/src/main/res/values/ic_launcher_background.xml b/examples/demo/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..c5d5899 --- /dev/null +++ b/examples/demo/android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file diff --git a/examples/demo/android/app/src/main/res/values/strings.xml b/examples/demo/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..0fce961 --- /dev/null +++ b/examples/demo/android/app/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ + + + OneSignal Demo + OneSignal Demo + com.onesignal.example + com.onesignal.example + diff --git a/examples/demo/android/app/src/main/res/values/styles.xml b/examples/demo/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..be874e5 --- /dev/null +++ b/examples/demo/android/app/src/main/res/values/styles.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/examples/demo/android/app/src/main/res/xml/file_paths.xml b/examples/demo/android/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..bd0c4d8 --- /dev/null +++ b/examples/demo/android/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/demo/android/build.gradle.kts b/examples/demo/android/build.gradle.kts new file mode 100644 index 0000000..8764441 --- /dev/null +++ b/examples/demo/android/build.gradle.kts @@ -0,0 +1,44 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath(libs.android.gradle.plugin) + classpath(libs.kotlin.gradle.plugin) + classpath(libs.google.services.plugin) + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +// Capture version catalog values outside the allprojects closure since `libs` +// accessors are only available in the root script body. +val minSdkVersion = libs.versions.minSdk.get().toInt() +val compileSdkVersion = libs.versions.compileSdk.get().toInt() +val targetSdkVersion = libs.versions.targetSdk.get().toInt() +val androidxAppCompatVersion = libs.versions.androidxAppCompat.get() +val cordovaAndroidVersion = libs.versions.cordovaAndroid.get() + +allprojects { + repositories { + google() + mavenCentral() + } + + // Expose version catalog values as project extras so the Capacitor-generated + // Groovy modules (capacitor-cordova-android-plugins) can resolve them via + // rootProject.ext.* without needing variables.gradle. + extra["minSdkVersion"] = minSdkVersion + extra["compileSdkVersion"] = compileSdkVersion + extra["targetSdkVersion"] = targetSdkVersion + extra["androidxAppCompatVersion"] = androidxAppCompatVersion + extra["cordovaAndroidVersion"] = cordovaAndroidVersion +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/examples/demo/android/capacitor.settings.gradle b/examples/demo/android/capacitor.settings.gradle new file mode 100644 index 0000000..26401ea --- /dev/null +++ b/examples/demo/android/capacitor.settings.gradle @@ -0,0 +1,12 @@ +// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN +include ':capacitor-android' +project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') + +include ':capacitor-keyboard' +project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor/keyboard/android') + +include ':capacitor-status-bar' +project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android') + +include ':onesignal-capacitor-plugin' +project(':onesignal-capacitor-plugin').projectDir = new File('../node_modules/onesignal-capacitor-plugin/android') diff --git a/examples/demo/android/gradle.properties b/examples/demo/android/gradle.properties new file mode 100644 index 0000000..2e87c52 --- /dev/null +++ b/examples/demo/android/gradle.properties @@ -0,0 +1,22 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true diff --git a/examples/demo/android/gradle/libs.versions.toml b/examples/demo/android/gradle/libs.versions.toml new file mode 100644 index 0000000..31df2a8 --- /dev/null +++ b/examples/demo/android/gradle/libs.versions.toml @@ -0,0 +1,35 @@ +[versions] +agp = "8.13.0" +kotlin = "2.1.20" +googleServices = "4.4.4" + +compileSdk = "36" +minSdk = "24" +targetSdk = "36" + +androidxActivity = "1.11.0" +androidxAppCompat = "1.7.1" +androidxCoordinatorLayout = "1.3.0" +androidxCore = "1.17.0" +androidxFragment = "1.8.9" +androidxWebkit = "1.14.0" +coreSplashScreen = "1.2.0" + +junit = "4.13.2" +androidxJunit = "1.3.0" +androidxEspressoCore = "3.7.0" + +cordovaAndroid = "14.0.1" + +[libraries] +android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +google-services-plugin = { module = "com.google.gms:google-services", version.ref = "googleServices" } + +androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidxAppCompat" } +androidx-coordinatorlayout = { module = "androidx.coordinatorlayout:coordinatorlayout", version.ref = "androidxCoordinatorLayout" } +androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashScreen" } + +junit = { module = "junit:junit", version.ref = "junit" } +androidx-test-junit = { module = "androidx.test.ext:junit", version.ref = "androidxJunit" } +androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidxEspressoCore" } diff --git a/examples/demo/android/gradle/wrapper/gradle-wrapper.jar b/examples/demo/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..1b33c55 Binary files /dev/null and b/examples/demo/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/demo/android/gradle/wrapper/gradle-wrapper.properties b/examples/demo/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7705927 --- /dev/null +++ b/examples/demo/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/examples/demo/android/gradlew b/examples/demo/android/gradlew new file mode 100755 index 0000000..23d15a9 --- /dev/null +++ b/examples/demo/android/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/examples/demo/android/gradlew.bat b/examples/demo/android/gradlew.bat new file mode 100644 index 0000000..5eed7ee --- /dev/null +++ b/examples/demo/android/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/examples/demo/android/settings.gradle.kts b/examples/demo/android/settings.gradle.kts new file mode 100644 index 0000000..8f492e5 --- /dev/null +++ b/examples/demo/android/settings.gradle.kts @@ -0,0 +1,5 @@ +include(":app") +include(":capacitor-cordova-android-plugins") +project(":capacitor-cordova-android-plugins").projectDir = file("./capacitor-cordova-android-plugins/") + +apply(from = "capacitor.settings.gradle") diff --git a/examples/demo/assets/icon-only.png b/examples/demo/assets/icon-only.png new file mode 100644 index 0000000..4ff809f Binary files /dev/null and b/examples/demo/assets/icon-only.png differ diff --git a/examples/demo/capacitor.config.ts b/examples/demo/capacitor.config.ts new file mode 100644 index 0000000..6ae21c8 --- /dev/null +++ b/examples/demo/capacitor.config.ts @@ -0,0 +1,12 @@ +import type { CapacitorConfig } from '@capacitor/cli'; + +const config: CapacitorConfig = { + appId: 'com.onesignal.example', + appName: 'OneSignal Demo', + webDir: 'dist', + ios: { + handleApplicationNotifications: false, + }, +}; + +export default config; diff --git a/examples/demo/index.html b/examples/demo/index.html new file mode 100644 index 0000000..195b310 --- /dev/null +++ b/examples/demo/index.html @@ -0,0 +1,15 @@ + + + + + + OneSignal Capacitor Demo + + +
+ + + diff --git a/examples/demo/ios/.gitignore b/examples/demo/ios/.gitignore new file mode 100644 index 0000000..f470299 --- /dev/null +++ b/examples/demo/ios/.gitignore @@ -0,0 +1,13 @@ +App/build +App/Pods +App/output +App/App/public +DerivedData +xcuserdata + +# Cordova plugins for Capacitor +capacitor-cordova-ios-plugins + +# Generated Config files +App/App/capacitor.config.json +App/App/config.xml diff --git a/examples/demo/ios/App/App.xcodeproj/project.pbxproj b/examples/demo/ios/App/App.xcodeproj/project.pbxproj new file mode 100644 index 0000000..8020248 --- /dev/null +++ b/examples/demo/ios/App/App.xcodeproj/project.pbxproj @@ -0,0 +1,754 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 70; + objects = { + +/* Begin PBXBuildFile section */ + 2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; }; + 4D22ABE92AF431CB00220026 /* CapApp-SPM in Frameworks */ = {isa = PBXBuildFile; productRef = 4D22ABE82AF431CB00220026 /* CapApp-SPM */; }; + 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; }; + 504EC3081FED79650016851F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F /* AppDelegate.swift */; }; + 504EC30D1FED79650016851F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F /* Main.storyboard */; }; + 504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; }; + 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; }; + 50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; }; + E82F344A2F981B4F0013F400 /* OneSignalNotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = E82F34432F981B4F0013F400 /* OneSignalNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + E82F34582F981C210013F400 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E82F34572F981C210013F400 /* WidgetKit.framework */; }; + E82F345A2F981C210013F400 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E82F34592F981C210013F400 /* SwiftUI.framework */; }; + E82F34672F981C230013F400 /* OneSignalWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = E82F34552F981C210013F400 /* OneSignalWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + E82F34482F981B4F0013F400 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 504EC2FC1FED79650016851F /* Project object */; + proxyType = 1; + remoteGlobalIDString = E82F34422F981B4F0013F400; + remoteInfo = OneSignalNotificationServiceExtension; + }; + E82F34652F981C230013F400 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 504EC2FC1FED79650016851F /* Project object */; + proxyType = 1; + remoteGlobalIDString = E82F34542F981C210013F400; + remoteInfo = OneSignalWidgetExtension; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + E82F344B2F981B4F0013F400 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + E82F344A2F981B4F0013F400 /* OneSignalNotificationServiceExtension.appex in Embed Foundation Extensions */, + E82F34672F981C230013F400 /* OneSignalWidgetExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = ""; }; + 50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = ""; }; + 504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 504EC3071FED79650016851F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 504EC30C1FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = ""; }; + 958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; }; + E82F34432F981B4F0013F400 /* OneSignalNotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OneSignalNotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + E82F34502F981B630013F400 /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = ""; }; + E82F34552F981C210013F400 /* OneSignalWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OneSignalWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + E82F34572F981C210013F400 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; + E82F34592F981C210013F400 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + E82F344E2F981B4F0013F400 /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = E82F34422F981B4F0013F400 /* OneSignalNotificationServiceExtension */; + }; + E82F34682F981C230013F400 /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = E82F34542F981C210013F400 /* OneSignalWidgetExtension */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + E82F34442F981B4F0013F400 /* OneSignalNotificationServiceExtension */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (E82F344E2F981B4F0013F400 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = OneSignalNotificationServiceExtension; sourceTree = ""; }; + E82F345B2F981C210013F400 /* OneSignalWidget */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (E82F34682F981C230013F400 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = OneSignalWidget; sourceTree = ""; }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 504EC3011FED79650016851F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4D22ABE92AF431CB00220026 /* CapApp-SPM in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E82F34402F981B4F0013F400 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E82F34522F981C210013F400 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E82F345A2F981C210013F400 /* SwiftUI.framework in Frameworks */, + E82F34582F981C210013F400 /* WidgetKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 504EC2FB1FED79650016851F = { + isa = PBXGroup; + children = ( + 958DCC722DB07C7200EA8C5F /* debug.xcconfig */, + 504EC3061FED79650016851F /* App */, + E82F34442F981B4F0013F400 /* OneSignalNotificationServiceExtension */, + E82F345B2F981C210013F400 /* OneSignalWidget */, + E82F34562F981C210013F400 /* Frameworks */, + 504EC3051FED79650016851F /* Products */, + ); + sourceTree = ""; + }; + 504EC3051FED79650016851F /* Products */ = { + isa = PBXGroup; + children = ( + 504EC3041FED79650016851F /* App.app */, + E82F34432F981B4F0013F400 /* OneSignalNotificationServiceExtension.appex */, + E82F34552F981C210013F400 /* OneSignalWidgetExtension.appex */, + ); + name = Products; + sourceTree = ""; + }; + 504EC3061FED79650016851F /* App */ = { + isa = PBXGroup; + children = ( + E82F34502F981B630013F400 /* App.entitlements */, + 50379B222058CBB4000EE86E /* capacitor.config.json */, + 504EC3071FED79650016851F /* AppDelegate.swift */, + 504EC30B1FED79650016851F /* Main.storyboard */, + 504EC30E1FED79650016851F /* Assets.xcassets */, + 504EC3101FED79650016851F /* LaunchScreen.storyboard */, + 504EC3131FED79650016851F /* Info.plist */, + 2FAD9762203C412B000D30F8 /* config.xml */, + 50B271D01FEDC1A000F3C39B /* public */, + ); + path = App; + sourceTree = ""; + }; + E82F34562F981C210013F400 /* Frameworks */ = { + isa = PBXGroup; + children = ( + E82F34572F981C210013F400 /* WidgetKit.framework */, + E82F34592F981C210013F400 /* SwiftUI.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 504EC3031FED79650016851F /* App */ = { + isa = PBXNativeTarget; + buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */; + buildPhases = ( + 504EC3001FED79650016851F /* Sources */, + 504EC3011FED79650016851F /* Frameworks */, + 504EC3021FED79650016851F /* Resources */, + E82F344B2F981B4F0013F400 /* Embed Foundation Extensions */, + ); + buildRules = ( + ); + dependencies = ( + E82F34492F981B4F0013F400 /* PBXTargetDependency */, + E82F34662F981C230013F400 /* PBXTargetDependency */, + ); + name = App; + packageProductDependencies = ( + 4D22ABE82AF431CB00220026 /* CapApp-SPM */, + ); + productName = App; + productReference = 504EC3041FED79650016851F /* App.app */; + productType = "com.apple.product-type.application"; + }; + E82F34422F981B4F0013F400 /* OneSignalNotificationServiceExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = E82F344F2F981B4F0013F400 /* Build configuration list for PBXNativeTarget "OneSignalNotificationServiceExtension" */; + buildPhases = ( + E82F343F2F981B4F0013F400 /* Sources */, + E82F34402F981B4F0013F400 /* Frameworks */, + E82F34412F981B4F0013F400 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + E82F34442F981B4F0013F400 /* OneSignalNotificationServiceExtension */, + ); + name = OneSignalNotificationServiceExtension; + packageProductDependencies = ( + ); + productName = OneSignalNotificationServiceExtension; + productReference = E82F34432F981B4F0013F400 /* OneSignalNotificationServiceExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; + E82F34542F981C210013F400 /* OneSignalWidgetExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = E82F34692F981C230013F400 /* Build configuration list for PBXNativeTarget "OneSignalWidgetExtension" */; + buildPhases = ( + E82F34512F981C210013F400 /* Sources */, + E82F34522F981C210013F400 /* Frameworks */, + E82F34532F981C210013F400 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + E82F345B2F981C210013F400 /* OneSignalWidget */, + ); + name = OneSignalWidgetExtension; + packageProductDependencies = ( + ); + productName = OneSignalWidgetExtension; + productReference = E82F34552F981C210013F400 /* OneSignalWidgetExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 504EC2FC1FED79650016851F /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 2620; + LastUpgradeCheck = 0920; + TargetAttributes = { + 504EC3031FED79650016851F = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + }; + E82F34422F981B4F0013F400 = { + CreatedOnToolsVersion = 26.2; + }; + E82F34542F981C210013F400 = { + CreatedOnToolsVersion = 26.2; + }; + }; + }; + buildConfigurationList = 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 504EC2FB1FED79650016851F; + packageReferences = ( + D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */, + ); + productRefGroup = 504EC3051FED79650016851F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 504EC3031FED79650016851F /* App */, + E82F34422F981B4F0013F400 /* OneSignalNotificationServiceExtension */, + E82F34542F981C210013F400 /* OneSignalWidgetExtension */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 504EC3021FED79650016851F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */, + 50B271D11FEDC1A000F3C39B /* public in Resources */, + 504EC30F1FED79650016851F /* Assets.xcassets in Resources */, + 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */, + 504EC30D1FED79650016851F /* Main.storyboard in Resources */, + 2FAD9763203C412B000D30F8 /* config.xml in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E82F34412F981B4F0013F400 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E82F34532F981C210013F400 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 504EC3001FED79650016851F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3081FED79650016851F /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E82F343F2F981B4F0013F400 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E82F34512F981C210013F400 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + E82F34492F981B4F0013F400 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = E82F34422F981B4F0013F400 /* OneSignalNotificationServiceExtension */; + targetProxy = E82F34482F981B4F0013F400 /* PBXContainerItemProxy */; + }; + E82F34662F981C230013F400 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = E82F34542F981C210013F400 /* OneSignalWidgetExtension */; + targetProxy = E82F34652F981C230013F400 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 504EC30B1FED79650016851F /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 504EC30C1FED79650016851F /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 504EC3101FED79650016851F /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 504EC3111FED79650016851F /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 504EC3141FED79650016851F /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 504EC3151FED79650016851F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 504EC3171FED79650016851F /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = App/App.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + INFOPLIST_FILE = App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; + PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 504EC3181FED79650016851F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = App/App.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + INFOPLIST_FILE = App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + E82F344C2F981B4F0013F400 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = OneSignalNotificationServiceExtension; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 26.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.NSE; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + E82F344D2F981B4F0013F400 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = OneSignalNotificationServiceExtension; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 26.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.NSE; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + E82F346A2F981C230013F400 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = OneSignalWidget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = OneSignalWidget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 26.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.LA; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + E82F346B2F981C230013F400 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = OneSignalWidget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = OneSignalWidget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 26.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.LA; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 504EC3141FED79650016851F /* Debug */, + 504EC3151FED79650016851F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 504EC3171FED79650016851F /* Debug */, + 504EC3181FED79650016851F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E82F344F2F981B4F0013F400 /* Build configuration list for PBXNativeTarget "OneSignalNotificationServiceExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E82F344C2F981B4F0013F400 /* Debug */, + E82F344D2F981B4F0013F400 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E82F34692F981C230013F400 /* Build configuration list for PBXNativeTarget "OneSignalWidgetExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E82F346A2F981C230013F400 /* Debug */, + E82F346B2F981C230013F400 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = "CapApp-SPM"; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 4D22ABE82AF431CB00220026 /* CapApp-SPM */ = { + isa = XCSwiftPackageProductDependency; + package = D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */; + productName = "CapApp-SPM"; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 504EC2FC1FED79650016851F /* Project object */; +} diff --git a/examples/demo/ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/examples/demo/ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/examples/demo/ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/examples/demo/ios/App/App/App.entitlements b/examples/demo/ios/App/App/App.entitlements new file mode 100644 index 0000000..3446364 --- /dev/null +++ b/examples/demo/ios/App/App/App.entitlements @@ -0,0 +1,12 @@ + + + + + aps-environment + development + com.apple.security.application-groups + + group.com.onesignal.example.onesignal + + + diff --git a/examples/demo/ios/App/App/AppDelegate.swift b/examples/demo/ios/App/App/AppDelegate.swift new file mode 100644 index 0000000..c3cd83b --- /dev/null +++ b/examples/demo/ios/App/App/AppDelegate.swift @@ -0,0 +1,49 @@ +import UIKit +import Capacitor + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { + // Called when the app was launched with a url. Feel free to add additional processing here, + // but if you want the App API to support tracking app url opens, make sure to keep this call + return ApplicationDelegateProxy.shared.application(app, open: url, options: options) + } + + func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { + // Called when the app was launched with an activity, including Universal Links. + // Feel free to add additional processing here, but if you want the App API to support + // tracking app url opens, make sure to keep this call + return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler) + } + +} diff --git a/examples/demo/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png b/examples/demo/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png new file mode 100644 index 0000000..adf6ba0 Binary files /dev/null and b/examples/demo/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png differ diff --git a/examples/demo/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/demo/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..00b5bd3 --- /dev/null +++ b/examples/demo/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images": [ + { + "filename": "AppIcon-512@2x.png", + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/examples/demo/ios/App/App/Assets.xcassets/Contents.json b/examples/demo/ios/App/App/Assets.xcassets/Contents.json new file mode 100644 index 0000000..97a8662 --- /dev/null +++ b/examples/demo/ios/App/App/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "version": 1, + "author": "xcode" + } +} diff --git a/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json b/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json new file mode 100644 index 0000000..b781492 --- /dev/null +++ b/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images": [ + { + "idiom": "universal", + "filename": "splash-2732x2732-2.png", + "scale": "1x" + }, + { + "idiom": "universal", + "filename": "splash-2732x2732-1.png", + "scale": "2x" + }, + { + "idiom": "universal", + "filename": "splash-2732x2732.png", + "scale": "3x" + } + ], + "info": { + "version": 1, + "author": "xcode" + } +} diff --git a/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png b/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png new file mode 100644 index 0000000..33ea6c9 Binary files /dev/null and b/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png differ diff --git a/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png b/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png new file mode 100644 index 0000000..33ea6c9 Binary files /dev/null and b/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png differ diff --git a/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png b/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png new file mode 100644 index 0000000..33ea6c9 Binary files /dev/null and b/examples/demo/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png differ diff --git a/examples/demo/ios/App/App/Base.lproj/LaunchScreen.storyboard b/examples/demo/ios/App/App/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..e7ae5d7 --- /dev/null +++ b/examples/demo/ios/App/App/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo/ios/App/App/Base.lproj/Main.storyboard b/examples/demo/ios/App/App/Base.lproj/Main.storyboard new file mode 100644 index 0000000..b44df7b --- /dev/null +++ b/examples/demo/ios/App/App/Base.lproj/Main.storyboard @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo/ios/App/App/Info.plist b/examples/demo/ios/App/App/Info.plist new file mode 100644 index 0000000..d051347 --- /dev/null +++ b/examples/demo/ios/App/App/Info.plist @@ -0,0 +1,57 @@ + + + + + NSSupportsLiveActivities + + CAPACITOR_DEBUG + $(CAPACITOR_DEBUG) + CFBundleDevelopmentRegion + en + CFBundleDisplayName + OneSignal Demo + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + LSRequiresIPhoneOS + + UIBackgroundModes + + remote-notification + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/examples/demo/ios/App/CapApp-SPM/.gitignore b/examples/demo/ios/App/CapApp-SPM/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/examples/demo/ios/App/CapApp-SPM/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/examples/demo/ios/App/CapApp-SPM/Package.swift b/examples/demo/ios/App/CapApp-SPM/Package.swift new file mode 100644 index 0000000..14b99d1 --- /dev/null +++ b/examples/demo/ios/App/CapApp-SPM/Package.swift @@ -0,0 +1,31 @@ +// swift-tools-version: 5.9 +import PackageDescription + +// DO NOT MODIFY THIS FILE - managed by Capacitor CLI commands +let package = Package( + name: "CapApp-SPM", + platforms: [.iOS(.v15)], + products: [ + .library( + name: "CapApp-SPM", + targets: ["CapApp-SPM"]) + ], + dependencies: [ + .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "8.3.1"), + .package(name: "CapacitorKeyboard", path: "../../../node_modules/@capacitor/keyboard"), + .package(name: "CapacitorStatusBar", path: "../../../node_modules/@capacitor/status-bar"), + .package(name: "OnesignalCapacitorPlugin", path: "../../../node_modules/onesignal-capacitor-plugin") + ], + targets: [ + .target( + name: "CapApp-SPM", + dependencies: [ + .product(name: "Capacitor", package: "capacitor-swift-pm"), + .product(name: "Cordova", package: "capacitor-swift-pm"), + .product(name: "CapacitorKeyboard", package: "CapacitorKeyboard"), + .product(name: "CapacitorStatusBar", package: "CapacitorStatusBar"), + .product(name: "OnesignalCapacitorPlugin", package: "OnesignalCapacitorPlugin") + ] + ) + ] +) diff --git a/examples/demo/ios/App/CapApp-SPM/README.md b/examples/demo/ios/App/CapApp-SPM/README.md new file mode 100644 index 0000000..03964db --- /dev/null +++ b/examples/demo/ios/App/CapApp-SPM/README.md @@ -0,0 +1,5 @@ +# CapApp-SPM + +This package is used to host SPM dependencies for your Capacitor project + +Do not modify the contents of it or there may be unintended consequences. diff --git a/examples/demo/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift b/examples/demo/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift new file mode 100644 index 0000000..945afec --- /dev/null +++ b/examples/demo/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift @@ -0,0 +1 @@ +public let isCapacitorApp = true diff --git a/examples/demo/ios/App/OneSignalNotificationServiceExtension/Info.plist b/examples/demo/ios/App/OneSignalNotificationServiceExtension/Info.plist new file mode 100644 index 0000000..57421eb --- /dev/null +++ b/examples/demo/ios/App/OneSignalNotificationServiceExtension/Info.plist @@ -0,0 +1,13 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.usernotifications.service + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).NotificationService + + + diff --git a/examples/demo/ios/App/OneSignalNotificationServiceExtension/NotificationService.swift b/examples/demo/ios/App/OneSignalNotificationServiceExtension/NotificationService.swift new file mode 100644 index 0000000..e45cd90 --- /dev/null +++ b/examples/demo/ios/App/OneSignalNotificationServiceExtension/NotificationService.swift @@ -0,0 +1,48 @@ +// FILE: OneSignalNotificationServiceExtension/NotificationService.swift +// PURPOSE: Enables rich notifications (images) and confirmed delivery analytics +// REQUIREMENT: This extension must share an App Group with the main app target (configured in next steps) +// WHEN IT RUNS: iOS calls this extension when a push has "mutable-content": true +// (automatically set when you include images or action buttons) + +import UserNotifications +import OneSignalExtension + +class NotificationService: UNNotificationServiceExtension { + + // Callback to deliver the modified notification to iOS + var contentHandler: ((UNNotificationContent) -> Void)? + + // The original push request from APNs + var receivedRequest: UNNotificationRequest! + + // A mutable copy of the notification we can modify (add images, etc.) + var bestAttemptContent: UNMutableNotificationContent? + + // Called when a push notification arrives with mutable-content: true + // You have ~30 seconds to modify the notification before iOS displays it + override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { + self.receivedRequest = request + self.contentHandler = contentHandler + self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) + + if let bestAttemptContent = bestAttemptContent { + // DEBUGGING: Uncomment to verify NSE is running + // bestAttemptContent.body = "[Modified] " + bestAttemptContent.body + + // OneSignal processes the notification: + // - Downloads and attaches images + // - Reports confirmed delivery to dashboard + // - Handles action buttons + OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler) + } + } + + // Called if didReceive() takes too long (~30 seconds) + // Delivers whatever content we have so the notification isn't lost + override func serviceExtensionTimeWillExpire() { + if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { + OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent) + contentHandler(bestAttemptContent) + } + } +} diff --git a/examples/demo/ios/App/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements b/examples/demo/ios/App/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements new file mode 100644 index 0000000..c70461e --- /dev/null +++ b/examples/demo/ios/App/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.onesignal.example.onesignal + + + diff --git a/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..0afb3cf --- /dev/null +++ b/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors": [ + { + "idiom": "universal" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..c70a5bf --- /dev/null +++ b/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,35 @@ +{ + "images": [ + { + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + }, + { + "appearances": [ + { + "appearance": "luminosity", + "value": "dark" + } + ], + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + }, + { + "appearances": [ + { + "appearance": "luminosity", + "value": "tinted" + } + ], + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/Contents.json b/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/Contents.json new file mode 100644 index 0000000..74d6a72 --- /dev/null +++ b/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json b/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 0000000..0afb3cf --- /dev/null +++ b/examples/demo/ios/App/OneSignalWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors": [ + { + "idiom": "universal" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/examples/demo/ios/App/OneSignalWidget/Info.plist b/examples/demo/ios/App/OneSignalWidget/Info.plist new file mode 100644 index 0000000..0f118fb --- /dev/null +++ b/examples/demo/ios/App/OneSignalWidget/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/examples/demo/ios/App/OneSignalWidget/OneSignalWidgetBundle.swift b/examples/demo/ios/App/OneSignalWidget/OneSignalWidgetBundle.swift new file mode 100644 index 0000000..a3004df --- /dev/null +++ b/examples/demo/ios/App/OneSignalWidget/OneSignalWidgetBundle.swift @@ -0,0 +1,16 @@ +// +// OneSignalWidgetBundle.swift +// OneSignalWidget +// +// Created by Fadi George on 4/21/26. +// + +import WidgetKit +import SwiftUI + +@main +struct OneSignalWidgetBundle: WidgetBundle { + var body: some Widget { + OneSignalWidgetLiveActivity() + } +} diff --git a/examples/demo/ios/App/OneSignalWidget/OneSignalWidgetLiveActivity.swift b/examples/demo/ios/App/OneSignalWidget/OneSignalWidgetLiveActivity.swift new file mode 100644 index 0000000..f4a95f7 --- /dev/null +++ b/examples/demo/ios/App/OneSignalWidget/OneSignalWidgetLiveActivity.swift @@ -0,0 +1,142 @@ +import ActivityKit +import WidgetKit +import SwiftUI +import OneSignalLiveActivities + +@available(iOS 16.2, *) +struct OneSignalWidgetLiveActivity: Widget { + + private func statusIcon(for status: String) -> String { + switch status { + case "on_the_way": return "box.truck.fill" + case "delivered": return "checkmark.circle.fill" + default: return "bag.fill" + } + } + + private func statusColor(for status: String) -> Color { + switch status { + case "on_the_way": return .blue + case "delivered": return .green + default: return .orange + } + } + + private func statusLabel(for status: String) -> String { + switch status { + case "on_the_way": return "On the Way" + case "delivered": return "Delivered" + default: return "Preparing" + } + } + + var body: some WidgetConfiguration { + ActivityConfiguration(for: DefaultLiveActivityAttributes.self) { context in + let orderNumber = context.attributes.data["orderNumber"]?.asString() ?? "Order" + let status = context.state.data["status"]?.asString() ?? "preparing" + let message = context.state.data["message"]?.asString() ?? "Your order is being prepared" + let eta = context.state.data["estimatedTime"]?.asString() ?? "" + + VStack(spacing: 10) { + HStack { + Text(orderNumber) + .font(.caption) + .foregroundColor(.gray) + Spacer() + if !eta.isEmpty { + Text(eta) + .font(.caption) + .foregroundColor(.white.opacity(0.7)) + } + } + + HStack(spacing: 12) { + Image(systemName: statusIcon(for: status)) + .font(.title2) + .foregroundColor(statusColor(for: status)) + + VStack(alignment: .leading, spacing: 2) { + Text(statusLabel(for: status)) + .font(.headline) + .foregroundColor(.white) + Text(message) + .font(.subheadline) + .foregroundColor(.white.opacity(0.8)) + .lineLimit(1) + } + Spacer() + } + + DeliveryProgressBar(status: status) + } + .padding() + .activityBackgroundTint(Color(red: 0.11, green: 0.13, blue: 0.19)) + .activitySystemActionForegroundColor(.white) + + } dynamicIsland: { context in + let status = context.state.data["status"]?.asString() ?? "preparing" + let message = context.state.data["message"]?.asString() ?? "Preparing" + let eta = context.state.data["estimatedTime"]?.asString() ?? "" + + return DynamicIsland { + DynamicIslandExpandedRegion(.leading) { + Image(systemName: statusIcon(for: status)) + .font(.title2) + .foregroundColor(statusColor(for: status)) + } + DynamicIslandExpandedRegion(.center) { + Text(statusLabel(for: status)) + .font(.headline) + } + DynamicIslandExpandedRegion(.trailing) { + if !eta.isEmpty { + Text(eta) + .font(.caption) + .foregroundColor(.secondary) + } + } + DynamicIslandExpandedRegion(.bottom) { + Text(message) + .font(.caption) + .foregroundColor(.secondary) + } + } compactLeading: { + Image(systemName: statusIcon(for: status)) + .foregroundColor(statusColor(for: status)) + } compactTrailing: { + Text(statusLabel(for: status)) + .font(.caption) + } minimal: { + Image(systemName: statusIcon(for: status)) + .foregroundColor(statusColor(for: status)) + } + } + } +} + +@available(iOS 16.2, *) +struct DeliveryProgressBar: View { + let status: String + + private var progress: CGFloat { + switch status { + case "on_the_way": return 0.6 + case "delivered": return 1.0 + default: return 0.25 + } + } + + var body: some View { + GeometryReader { geo in + ZStack(alignment: .leading) { + RoundedRectangle(cornerRadius: 3) + .fill(Color.white.opacity(0.2)) + .frame(height: 6) + RoundedRectangle(cornerRadius: 3) + .fill(progress >= 1.0 ? Color.green : Color.blue) + .frame(width: geo.size.width * progress, height: 6) + } + } + .frame(height: 6) + } +} diff --git a/examples/demo/ios/debug.xcconfig b/examples/demo/ios/debug.xcconfig new file mode 100644 index 0000000..53ce18d --- /dev/null +++ b/examples/demo/ios/debug.xcconfig @@ -0,0 +1 @@ +CAPACITOR_DEBUG = true diff --git a/examples/demo/package.json b/examples/demo/package.json new file mode 100644 index 0000000..545ac3e --- /dev/null +++ b/examples/demo/package.json @@ -0,0 +1,48 @@ +{ + "name": "demo", + "version": "1.0.0", + "private": true, + "type": "module", + "scripts": { + "android": "bash ../run-android.sh", + "build": "vp build", + "clean:android": "rm -rf android/app/build android/app/.cxx android/build", + "clean:ios": "rm -rf ios/App/build ios/DerivedData ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/swiftpm", + "ios": "bash ../run-ios.sh", + "preandroid": "bun run setup", + "preios": "bun run setup", + "setup": "../setup.sh" + }, + "dependencies": { + "@capacitor/android": "^8.3.0", + "@capacitor/core": "^8.3.0", + "@capacitor/ios": "^8.3.0", + "@capacitor/keyboard": "^8.0.2", + "@capacitor/status-bar": "^8.0.2", + "@ionic/react": "^8.8.3", + "@ionic/react-router": "^8.8.3", + "ionicons": "^7.4.0", + "onesignal-capacitor-plugin": "file:../../onesignal-capacitor-plugin.tgz", + "react": "^19.2.4", + "react-dom": "^19.2.4", + "react-icons": "^5.6.0", + "react-router": "^5.3.4", + "react-router-dom": "^5.3.4" + }, + "devDependencies": { + "@capacitor/cli": "^8.3.0", + "@types/react": "^19.2.14", + "@types/react-dom": "^19.2.3", + "@types/react-router": "^5.1.20", + "@types/react-router-dom": "^5.3.3", + "@vitejs/plugin-react": "^6.0.1", + "typescript": "^6.0.2", + "vite": "npm:@voidzero-dev/vite-plus-core@latest", + "vite-plus": "0.1.15" + }, + "overrides": { + "vite": "npm:@voidzero-dev/vite-plus-core@latest", + "vitest": "npm:@voidzero-dev/vite-plus-test@latest" + }, + "packageManager": "bun@1.3.11" +} diff --git a/examples/demo/src/App.tsx b/examples/demo/src/App.tsx new file mode 100644 index 0000000..71cb36f --- /dev/null +++ b/examples/demo/src/App.tsx @@ -0,0 +1,49 @@ +import { StatusBar, Style } from '@capacitor/status-bar'; +import { IonApp, IonRouterOutlet, setupIonicReact } from '@ionic/react'; +import { IonReactRouter } from '@ionic/react-router'; +import { Redirect, Route } from 'react-router-dom'; + +import HomeScreen from './pages/HomeScreen'; +import Secondary from './pages/Secondary'; + +/* Core CSS required for Ionic components to work properly */ +import '@ionic/react/css/core.css'; +/* Basic CSS for apps built with Ionic */ +import '@ionic/react/css/normalize.css'; +import '@ionic/react/css/structure.css'; +import '@ionic/react/css/typography.css'; +/* Optional CSS utils that can be commented out */ +import '@ionic/react/css/display.css'; +import '@ionic/react/css/flex-utils.css'; +import '@ionic/react/css/float-elements.css'; +import '@ionic/react/css/padding.css'; +import '@ionic/react/css/text-alignment.css'; +import '@ionic/react/css/text-transformation.css'; +/* Ionic Dark Mode */ +import '@ionic/react/css/palettes/dark.system.css'; +/* Theme variables */ +import './theme/variables.css'; + +StatusBar.setStyle({ style: Style.Dark }).catch(() => {}); + +setupIonicReact(); + +const App: React.FC = () => ( + + + + + + + + + + + + + + + +); + +export default App; diff --git a/examples/demo/src/assets/onesignal_logo.svg b/examples/demo/src/assets/onesignal_logo.svg new file mode 100644 index 0000000..79bfe39 --- /dev/null +++ b/examples/demo/src/assets/onesignal_logo.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo/src/components/ActionButton.tsx b/examples/demo/src/components/ActionButton.tsx new file mode 100644 index 0000000..b91f81e --- /dev/null +++ b/examples/demo/src/components/ActionButton.tsx @@ -0,0 +1,14 @@ +import type { ButtonHTMLAttributes, FC } from 'react'; + +type Variant = 'primary' | 'outline'; + +interface ActionButtonProps extends ButtonHTMLAttributes { + variant?: Variant; +} + +const ActionButton: FC = ({ variant = 'primary', className = '', ...props }) => { + const variantClass = variant === 'outline' ? 'action-btn outline' : 'action-btn'; + return + ) : null} + + ))} + + ); +}; + +export const SingleList: FC = ({ + items, + emptyText, + onRemove, + loading = false, + sectionKey, +}) => { + const [expanded, setExpanded] = useState(false); + const showAll = expanded || items.length <= COLLAPSE_THRESHOLD; + const displayItems = showAll ? items : items.slice(0, COLLAPSE_THRESHOLD); + const hiddenCount = items.length - COLLAPSE_THRESHOLD; + + if (items.length === 0) { + return ( +
+ {loading ? ( + + ) : ( + + )} +
+ ); + } + + return ( +
+ {displayItems.map((item) => ( +
+ {item} + {onRemove ? ( + + ) : null} +
+ ))} + {!showAll && hiddenCount > 0 && ( + + )} +
+ ); +}; diff --git a/examples/demo/src/components/SectionCard.tsx b/examples/demo/src/components/SectionCard.tsx new file mode 100644 index 0000000..a5241d6 --- /dev/null +++ b/examples/demo/src/components/SectionCard.tsx @@ -0,0 +1,31 @@ +import type { FC, ReactNode } from 'react'; +import { MdInfoOutline } from 'react-icons/md'; + +interface SectionCardProps { + title: string; + sectionKey?: string; + onInfoTap?: () => void; + children: ReactNode; +} + +const SectionCard: FC = ({ title, sectionKey, onInfoTap, children }) => ( +
+
+

{title}

+ {onInfoTap ? ( + + ) : null} +
+ {children} +
+); + +export default SectionCard; diff --git a/examples/demo/src/components/ToggleRow.tsx b/examples/demo/src/components/ToggleRow.tsx new file mode 100644 index 0000000..a5c06f9 --- /dev/null +++ b/examples/demo/src/components/ToggleRow.tsx @@ -0,0 +1,26 @@ +import { IonToggle } from '@ionic/react'; +import type { FC } from 'react'; + +interface ToggleRowProps { + label: string; + description?: string; + checked: boolean; + onToggle: (checked: boolean) => void; + testId?: string; +} + +const ToggleRow: FC = ({ label, description, checked, onToggle, testId }) => ( +
+
+
{label}
+ {description ?
{description}
: null} +
+ onToggle(event.detail.checked)} + data-testid={testId} + /> +
+); + +export default ToggleRow; diff --git a/examples/demo/src/components/modals/CustomNotificationModal.tsx b/examples/demo/src/components/modals/CustomNotificationModal.tsx new file mode 100644 index 0000000..4b13364 --- /dev/null +++ b/examples/demo/src/components/modals/CustomNotificationModal.tsx @@ -0,0 +1,64 @@ +import type { FC } from 'react'; +import { useEffect, useState } from 'react'; + +import ModalShell from './ModalShell'; + +interface CustomNotificationModalProps { + open: boolean; + onClose: () => void; + onSubmit: (title: string, body: string) => void; +} + +const CustomNotificationModal: FC = ({ open, onClose, onSubmit }) => { + const [title, setTitle] = useState(''); + const [body, setBody] = useState(''); + + useEffect(() => { + if (open) { + setTitle(''); + setBody(''); + } + }, [open]); + + return ( + +
{ + event.preventDefault(); + const trimmedTitle = title.trim(); + const trimmedBody = body.trim(); + if (!trimmedTitle || !trimmedBody) return; + onSubmit(trimmedTitle, trimmedBody); + }} + > +

Custom Notification

+ setTitle(event.target.value)} + placeholder="Title" + data-testid="custom_notification_title_input" + /> + setBody(event.target.value)} + placeholder="Body" + data-testid="custom_notification_body_input" + /> +
+ + +
+
+
+ ); +}; + +export default CustomNotificationModal; diff --git a/examples/demo/src/components/modals/ModalShell.tsx b/examples/demo/src/components/modals/ModalShell.tsx new file mode 100644 index 0000000..a095074 --- /dev/null +++ b/examples/demo/src/components/modals/ModalShell.tsx @@ -0,0 +1,17 @@ +import type { FC, ReactNode } from 'react'; + +interface ModalShellProps { + open: boolean; + children: ReactNode; +} + +const ModalShell: FC = ({ open, children }) => { + if (!open) return null; + return ( +
+
{children}
+
+ ); +}; + +export default ModalShell; diff --git a/examples/demo/src/components/modals/MultiPairInputModal.tsx b/examples/demo/src/components/modals/MultiPairInputModal.tsx new file mode 100644 index 0000000..03a5f5f --- /dev/null +++ b/examples/demo/src/components/modals/MultiPairInputModal.tsx @@ -0,0 +1,122 @@ +import { useEffect, useMemo, useState } from 'react'; +import type { FC } from 'react'; +import { MdClose } from 'react-icons/md'; + +import ModalShell from './ModalShell'; + +type Row = { key: string; value: string }; + +interface MultiPairInputModalProps { + open: boolean; + title: string; + keyPlaceholder: string; + valuePlaceholder: string; + onClose: () => void; + onSubmit: (pairs: Record) => void; +} + +const MultiPairInputModal: FC = ({ + open, + title, + keyPlaceholder, + valuePlaceholder, + onClose, + onSubmit, +}) => { + const [rows, setRows] = useState([{ key: '', value: '' }]); + + useEffect(() => { + if (open) { + setRows([{ key: '', value: '' }]); + } + }, [open]); + + const isValid = useMemo( + () => + rows.length > 0 && + rows.every((row) => row.key.trim().length > 0 && row.value.trim().length > 0), + [rows], + ); + + return ( + +
{ + event.preventDefault(); + if (!isValid) return; + const pairs: Record = {}; + rows.forEach((row) => { + pairs[row.key.trim()] = row.value.trim(); + }); + onSubmit(pairs); + }} + > +

{title}

+ {rows.map((row, index) => ( +
+
+ + setRows((prev) => + prev.map((entry, entryIndex) => + entryIndex === index ? { ...entry, key: event.target.value } : entry, + ), + ) + } + placeholder={keyPlaceholder} + data-testid={`multipair_key_${index}`} + /> + + setRows((prev) => + prev.map((entry, entryIndex) => + entryIndex === index ? { ...entry, value: event.target.value } : entry, + ), + ) + } + placeholder={valuePlaceholder} + data-testid={`multipair_value_${index}`} + /> + {rows.length > 1 ? ( + + ) : null} +
+ {index < rows.length - 1 ?
: null} +
+ ))} + +
+ + +
+ + + ); +}; + +export default MultiPairInputModal; diff --git a/examples/demo/src/components/modals/MultiSelectRemoveModal.tsx b/examples/demo/src/components/modals/MultiSelectRemoveModal.tsx new file mode 100644 index 0000000..ae533db --- /dev/null +++ b/examples/demo/src/components/modals/MultiSelectRemoveModal.tsx @@ -0,0 +1,70 @@ +import { useEffect, useState } from 'react'; +import type { FC } from 'react'; + +import ModalShell from './ModalShell'; + +interface MultiSelectRemoveModalProps { + open: boolean; + title: string; + items: [string, string][]; + onClose: () => void; + onSubmit: (keys: string[]) => void; +} + +const MultiSelectRemoveModal: FC = ({ + open, + title, + items, + onClose, + onSubmit, +}) => { + const [selectedKeys, setSelectedKeys] = useState([]); + + useEffect(() => { + if (open) { + setSelectedKeys([]); + } + }, [open]); + + return ( + +
+

{title}

+
+ {items.map(([key]) => ( + + ))} +
+
+ + +
+
+
+ ); +}; + +export default MultiSelectRemoveModal; diff --git a/examples/demo/src/components/modals/OutcomeModal.tsx b/examples/demo/src/components/modals/OutcomeModal.tsx new file mode 100644 index 0000000..5e44efb --- /dev/null +++ b/examples/demo/src/components/modals/OutcomeModal.tsx @@ -0,0 +1,106 @@ +import { useEffect, useState } from 'react'; +import type { FC } from 'react'; + +import ModalShell from './ModalShell'; + +export type OutcomeMode = 'normal' | 'unique' | 'value'; + +interface OutcomeModalProps { + open: boolean; + onClose: () => void; + onSubmit: (name: string, mode: OutcomeMode, value: number | null) => void; +} + +const OutcomeModal: FC = ({ open, onClose, onSubmit }) => { + const [mode, setMode] = useState('normal'); + const [name, setName] = useState(''); + const [value, setValue] = useState(''); + + useEffect(() => { + if (open) { + setMode('normal'); + setName(''); + setValue(''); + } + }, [open]); + + return ( + +
{ + event.preventDefault(); + const trimmed = name.trim(); + if (!trimmed) return; + if (mode === 'value') { + const numericValue = Number(value); + if (Number.isNaN(numericValue)) return; + onSubmit(trimmed, mode, numericValue); + return; + } + onSubmit(trimmed, mode, null); + }} + > +

Send Outcome

+
+ + + +
+ setName(event.target.value)} + placeholder="Outcome Name" + data-testid="outcome_name_input" + /> + {mode === 'value' ? ( + setValue(event.target.value)} + placeholder="Outcome Value" + data-testid="outcome_value_input" + /> + ) : null} +
+ + +
+
+
+ ); +}; + +export default OutcomeModal; diff --git a/examples/demo/src/components/modals/PairInputModal.tsx b/examples/demo/src/components/modals/PairInputModal.tsx new file mode 100644 index 0000000..670f9d1 --- /dev/null +++ b/examples/demo/src/components/modals/PairInputModal.tsx @@ -0,0 +1,82 @@ +import { useEffect, useState } from 'react'; +import type { FC } from 'react'; + +import ModalShell from './ModalShell'; + +interface PairInputModalProps { + open: boolean; + title: string; + keyPlaceholder: string; + valuePlaceholder: string; + confirmLabel: string; + onClose: () => void; + onSubmit: (key: string, value: string) => void; + keyTestID?: string; + valueTestID?: string; +} + +const PairInputModal: FC = ({ + open, + title, + keyPlaceholder, + valuePlaceholder, + confirmLabel, + onClose, + onSubmit, + keyTestID, + valueTestID, +}) => { + const [key, setKey] = useState(''); + const [value, setValue] = useState(''); + + useEffect(() => { + if (open) { + setKey(''); + setValue(''); + } + }, [open]); + + return ( + +
{ + event.preventDefault(); + const trimmedKey = key.trim(); + const trimmedValue = value.trim(); + if (!trimmedKey || !trimmedValue) return; + onSubmit(trimmedKey, trimmedValue); + }} + > +

{title}

+
+ setKey(event.target.value)} + placeholder={keyPlaceholder} + data-testid={keyTestID} + /> + setValue(event.target.value)} + placeholder={valuePlaceholder} + data-testid={valueTestID} + /> +
+
+ + +
+
+
+ ); +}; + +export default PairInputModal; diff --git a/examples/demo/src/components/modals/SingleInputModal.tsx b/examples/demo/src/components/modals/SingleInputModal.tsx new file mode 100644 index 0000000..6b321b1 --- /dev/null +++ b/examples/demo/src/components/modals/SingleInputModal.tsx @@ -0,0 +1,67 @@ +import { useEffect, useState } from 'react'; +import type { FC } from 'react'; + +import ModalShell from './ModalShell'; + +interface SingleInputModalProps { + open: boolean; + title: string; + placeholder: string; + confirmLabel: string; + onClose: () => void; + onSubmit: (value: string) => void; + inputTestId?: string; +} + +const SingleInputModal: FC = ({ + open, + title, + placeholder, + confirmLabel, + onClose, + onSubmit, + inputTestId, +}) => { + const [value, setValue] = useState(''); + + useEffect(() => { + if (open) { + setValue(''); + } + }, [open]); + + return ( + +
{ + event.preventDefault(); + const trimmed = value.trim(); + if (!trimmed) return; + onSubmit(trimmed); + }} + > +

{title}

+ setValue(event.target.value)} + placeholder={placeholder} + data-testid={inputTestId} + /> +
+ + +
+
+
+ ); +}; + +export default SingleInputModal; diff --git a/examples/demo/src/components/modals/TooltipModal.tsx b/examples/demo/src/components/modals/TooltipModal.tsx new file mode 100644 index 0000000..1b190f5 --- /dev/null +++ b/examples/demo/src/components/modals/TooltipModal.tsx @@ -0,0 +1,34 @@ +import type { FC } from 'react'; + +import type { TooltipData } from '../../services/TooltipHelper'; +import ModalShell from './ModalShell'; + +interface TooltipModalProps { + open: boolean; + tooltip: TooltipData | null; + onClose: () => void; +} + +const TooltipModal: FC = ({ open, tooltip, onClose }) => ( + +

{tooltip?.title ?? 'Info'}

+

{tooltip?.description ?? ''}

+ {tooltip?.options?.length ? ( +
+ {tooltip.options.map((option) => ( +
+ {option.name} +

{option.description}

+
+ ))} +
+ ) : null} +
+ +
+
+); + +export default TooltipModal; diff --git a/examples/demo/src/components/modals/TrackEventModal.tsx b/examples/demo/src/components/modals/TrackEventModal.tsx new file mode 100644 index 0000000..da5fdd0 --- /dev/null +++ b/examples/demo/src/components/modals/TrackEventModal.tsx @@ -0,0 +1,86 @@ +import { useEffect, useState } from 'react'; +import type { FC } from 'react'; + +import ModalShell from './ModalShell'; + +function isRecord(value: unknown): value is Record { + return Boolean(value) && typeof value === 'object' && !Array.isArray(value); +} + +interface TrackEventModalProps { + open: boolean; + onClose: () => void; + onSubmit: (name: string, properties?: Record) => void; +} + +const TrackEventModal: FC = ({ open, onClose, onSubmit }) => { + const [name, setName] = useState(''); + const [properties, setProperties] = useState(''); + const [error, setError] = useState(null); + + useEffect(() => { + if (open) { + setName(''); + setProperties(''); + setError(null); + } + }, [open]); + + return ( + +
{ + event.preventDefault(); + const trimmedName = name.trim(); + if (!trimmedName) return; + if (!properties.trim()) { + onSubmit(trimmedName, undefined); + return; + } + try { + const parsed = JSON.parse(properties); + if (!isRecord(parsed)) { + setError('Properties must be a JSON object'); + return; + } + onSubmit(trimmedName, parsed); + } catch { + setError('Properties must be valid JSON'); + } + }} + > +

Track Event

+ setName(event.target.value)} + placeholder="Event Name" + data-testid="event_name_input" + /> +