diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index b55bfd7..5cc6f13 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -137,8 +137,8 @@ jobs: exit 1 fi - sed -i '' "s/s\.dependency 'OneSignalXCFramework', '[^']*'/s.dependency 'OneSignalXCFramework', '$VERSION'/" OneSignalCapacitorPlugin.podspec - echo "✓ Updated OneSignalCapacitorPlugin.podspec with iOS SDK ${VERSION}" + sed -i '' "s/s\.dependency 'OneSignalXCFramework', '[^']*'/s.dependency 'OneSignalXCFramework', '$VERSION'/" OnesignalCapacitorPlugin.podspec + echo "✓ Updated OnesignalCapacitorPlugin.podspec with iOS SDK ${VERSION}" # Only commit if there are changes git add -A diff --git a/.gitignore b/.gitignore index 9942827..b0bf4e5 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,23 @@ local.properties *.apk *.dex *.class + +# Secrets +.env + +# Examples +examples/*/node_modules +examples/*/bun.lock +examples/*/dist +examples/*/android/app/build +examples/*/android/app/.cxx +examples/*/android/.gradle +examples/*/android/.idea +examples/*/android/build +examples/*/android/local.properties +examples/*/android/capacitor.build.gradle +examples/*/ios/App/Pods +examples/*/ios/App/Podfile.lock +examples/*/ios/App/App.xcworkspace/xcshareddata +examples/*/ios/App/App.xcworkspace/xcuserdata +examples/*/ios/App/DerivedData diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..f555abb --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["redhat.vscode-yaml", "VoidZero.vite-plus-extension-pack"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b653bd4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "editor.defaultFormatter": "oxc.oxc-vscode", + "oxc.fmt.configPath": "./vite.config.ts", + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "file", + "editor.codeActionsOnSave": { + "source.fixAll.oxc": "explicit" + } +} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..8573476 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,76 @@ + + +# Using Vite+, the Unified Toolchain for the Web + +This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, but it invokes Vite through `vp dev` and `vp build`. + +## Vite+ Workflow + +`vp` is a global binary that handles the full development lifecycle. Run `vp help` to print a list of commands and `vp --help` for information about a specific command. + +### Start + +- create - Create a new project from a template +- migrate - Migrate an existing project to Vite+ +- config - Configure hooks and agent integration +- staged - Run linters on staged files +- install (`i`) - Install dependencies +- env - Manage Node.js versions + +### Develop + +- dev - Run the development server +- check - Run format, lint, and TypeScript type checks +- lint - Lint code +- fmt - Format code +- test - Run tests + +### Execute + +- run - Run monorepo tasks +- exec - Execute a command from local `node_modules/.bin` +- dlx - Execute a package binary without installing it as a dependency +- cache - Manage the task cache + +### Build + +- build - Build for production +- pack - Build libraries +- preview - Preview production build + +### Manage Dependencies + +Vite+ automatically detects and wraps the underlying package manager such as pnpm, npm, or Yarn through the `packageManager` field in `package.json` or package manager-specific lockfiles. + +- add - Add packages to dependencies +- remove (`rm`, `un`, `uninstall`) - Remove packages from dependencies +- update (`up`) - Update packages to latest versions +- dedupe - Deduplicate dependencies +- outdated - Check for outdated packages +- list (`ls`) - List installed packages +- why (`explain`) - Show why a package is installed +- info (`view`, `show`) - View package information from the registry +- link (`ln`) / unlink - Manage local package links +- pm - Forward a command to the package manager + +### Maintain + +- upgrade - Update `vp` itself to the latest version + +These commands map to their corresponding tools. For example, `vp dev --port 3000` runs Vite's dev server and works the same as Vite. `vp test` runs JavaScript tests through the bundled Vitest. The version of all tools can be checked using `vp --version`. This is useful when researching documentation, features, and bugs. + +## Common Pitfalls + +- **Using the package manager directly:** Do not use pnpm, npm, or Yarn directly. Vite+ can handle all package manager operations. +- **Always use Vite commands to run tools:** Don't attempt to run `vp vitest` or `vp oxlint`. They do not exist. Use `vp test` and `vp lint` instead. +- **Running scripts:** Vite+ commands take precedence over `package.json` scripts. If there is a `test` script defined in `scripts` that conflicts with the built-in `vp test` command, run it using `vp run test`. +- **Do not install Vitest, Oxlint, Oxfmt, or tsdown directly:** Vite+ wraps these tools. They must not be installed directly. You cannot upgrade these tools by installing their latest versions. Always use Vite+ commands. +- **Use Vite+ wrappers for one-off binaries:** Use `vp dlx` instead of package-manager-specific `dlx`/`npx` commands. +- **Import JavaScript modules from `vite-plus`:** Instead of importing from `vite` or `vitest`, all modules should be imported from the project's `vite-plus` dependency. For example, `import { defineConfig } from 'vite-plus';` or `import { expect, test, vi } from 'vite-plus/test';`. You must not install `vitest` to import test utilities. +- **Type-Aware Linting:** There is no need to install `oxlint-tsgolint`, `vp lint --type-aware` works out of the box. + +## Review Checklist for Agents + +- [ ] Run `vp install` after pulling remote changes and before getting started. +- [ ] Run `vp check` and `vp test` to validate changes. + diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..5315c36 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @OneSignal/eng-sdk-platform diff --git a/OneSignalCapacitorPlugin.podspec b/OneSignalCapacitorPlugin.podspec index 8b973a8..e4d8802 100644 --- a/OneSignalCapacitorPlugin.podspec +++ b/OneSignalCapacitorPlugin.podspec @@ -3,7 +3,7 @@ require 'json' package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) Pod::Spec.new do |s| - s.name = 'OneSignalCapacitorPlugin' + s.name = 'OnesignalCapacitorPlugin' s.version = package['version'] s.summary = 'OneSignal Push Notifications Capacitor Plugin' s.license = package['license'] diff --git a/android/src/main/kotlin/com/onesignal/capacitor/OneSignalCapacitorPlugin.kt b/android/src/main/kotlin/com/onesignal/capacitor/OneSignalCapacitorPlugin.kt index 54f4f9b..1eb202c 100644 --- a/android/src/main/kotlin/com/onesignal/capacitor/OneSignalCapacitorPlugin.kt +++ b/android/src/main/kotlin/com/onesignal/capacitor/OneSignalCapacitorPlugin.kt @@ -18,6 +18,15 @@ import com.onesignal.notifications.INotificationClickEvent import com.onesignal.notifications.INotificationClickListener import com.onesignal.notifications.INotificationLifecycleListener import com.onesignal.notifications.INotificationWillDisplayEvent +import com.onesignal.notifications.IPermissionObserver +import com.onesignal.user.state.IUserStateObserver +import com.onesignal.user.state.UserChangedState +import com.onesignal.user.subscriptions.IPushSubscriptionObserver +import com.onesignal.user.subscriptions.PushSubscriptionChangedState +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import org.json.JSONArray import org.json.JSONObject @CapacitorPlugin(name = "OneSignalCapacitor") @@ -45,48 +54,57 @@ class OneSignalCapacitorPlugin : Plugin(), OneSignalWrapper.sdkVersion = "010000" OneSignal.initWithContext(context, appId) - OneSignal.Notifications.addPermissionObserver { permission -> - val ret = JSObject() - ret.put("permission", permission) - notifyListeners("permissionChange", ret) - } + OneSignal.Notifications.addPermissionObserver(object : IPermissionObserver { + override fun onNotificationPermissionChange(permission: Boolean) { + val ret = JSObject() + ret.put("permission", permission) + notifyListeners("permissionChange", ret) + } + }) OneSignal.Notifications.addForegroundLifecycleListener(this) OneSignal.Notifications.addClickListener(this) - OneSignal.User.pushSubscription.addObserver { state -> - val ret = JSObject() - val prev = JSObject() - prev.put("id", state.previous.id ?: JSONObject.NULL) - prev.put("token", state.previous.token ?: JSONObject.NULL) - prev.put("optedIn", state.previous.optedIn) - ret.put("previous", prev) - - val curr = JSObject() - curr.put("id", state.current.id ?: JSONObject.NULL) - curr.put("token", state.current.token ?: JSONObject.NULL) - curr.put("optedIn", state.current.optedIn) - ret.put("current", curr) - - notifyListeners("pushSubscriptionChange", ret) - } - - OneSignal.User.addObserver { state -> - val ret = JSObject() - val curr = JSObject() - curr.put("onesignalId", state.current.onesignalId ?: JSONObject.NULL) - curr.put("externalId", state.current.externalId ?: JSONObject.NULL) - ret.put("current", curr) - notifyListeners("userStateChange", ret) - } + OneSignal.User.pushSubscription.addObserver(object : IPushSubscriptionObserver { + override fun onPushSubscriptionChange(state: PushSubscriptionChangedState) { + val ret = JSObject() + val prev = JSObject() + prev.put("id", state.previous.id.ifEmpty { JSONObject.NULL }) + prev.put("token", state.previous.token.ifEmpty { JSONObject.NULL }) + prev.put("optedIn", state.previous.optedIn) + ret.put("previous", prev) + + val curr = JSObject() + curr.put("id", state.current.id.ifEmpty { JSONObject.NULL }) + curr.put("token", state.current.token.ifEmpty { JSONObject.NULL }) + curr.put("optedIn", state.current.optedIn) + ret.put("current", curr) + + notifyListeners("pushSubscriptionChange", ret) + } + }) + + OneSignal.User.addObserver(object : IUserStateObserver { + override fun onUserStateChange(state: UserChangedState) { + val ret = JSObject() + val curr = JSObject() + curr.put("onesignalId", state.current.onesignalId.ifEmpty { JSONObject.NULL }) + curr.put("externalId", state.current.externalId.ifEmpty { JSONObject.NULL }) + ret.put("current", curr) + notifyListeners("userStateChange", ret) + } + }) OneSignal.InAppMessages.addLifecycleListener(this) OneSignal.InAppMessages.addClickListener(this) pendingClickEvent?.let { event -> val ret = JSObject() - ret.put("result", JSObject(event.result.toJSONObject().toString())) - ret.put("notification", JSObject(event.notification.toJSONObject().toString())) + val clickResult = JSObject() + clickResult.put("actionId", event.result.actionId) + clickResult.put("url", event.result.url) + ret.put("result", clickResult) + ret.put("notification", JSObject(event.notification.rawPayload)) notifyListeners("notificationClick", ret) pendingClickEvent = null } @@ -114,14 +132,14 @@ class OneSignalCapacitorPlugin : Plugin(), @PluginMethod fun setConsentRequired(call: PluginCall) { val required = call.getBoolean("required") ?: false - OneSignal.setConsentRequired(required) + OneSignal.consentRequired = required call.resolve() } @PluginMethod fun setConsentGiven(call: PluginCall) { val granted = call.getBoolean("granted") ?: false - OneSignal.setConsentGiven(granted) + OneSignal.consentGiven = granted call.resolve() } @@ -165,7 +183,7 @@ class OneSignalCapacitorPlugin : Plugin(), return } val aliases = mutableMapOf() - aliasesObj.keys().forEach { key -> aliases[key] = aliasesObj.getString(key) } + aliasesObj.keys().forEach { key -> aliasesObj.getString(key)?.let { aliases[key] = it } } OneSignal.User.addAliases(aliases) call.resolve() } @@ -235,7 +253,7 @@ class OneSignalCapacitorPlugin : Plugin(), return } val tags = mutableMapOf() - tagsObj.keys().forEach { key -> tags[key] = tagsObj.getString(key) } + tagsObj.keys().forEach { key -> tagsObj.getString(key)?.let { tags[key] = it } } OneSignal.User.addTags(tags) call.resolve() } @@ -267,14 +285,14 @@ class OneSignalCapacitorPlugin : Plugin(), @PluginMethod fun getOnesignalId(call: PluginCall) { val ret = JSObject() - ret.put("onesignalId", OneSignal.User.onesignalId ?: JSONObject.NULL) + ret.put("onesignalId", OneSignal.User.onesignalId.ifEmpty { JSONObject.NULL }) call.resolve(ret) } @PluginMethod fun getExternalId(call: PluginCall) { val ret = JSObject() - ret.put("externalId", OneSignal.User.externalId ?: JSONObject.NULL) + ret.put("externalId", OneSignal.User.externalId.ifEmpty { JSONObject.NULL }) call.resolve(ret) } @@ -286,18 +304,37 @@ class OneSignalCapacitorPlugin : Plugin(), return } val propertiesObj = call.getObject("properties") - val properties = if (propertiesObj != null) { - val map = mutableMapOf() - propertiesObj.keys().forEach { key -> - map[key] = propertiesObj.get(key) - } - map - } else null + val properties = propertiesObj?.let { jsonObjectToMap(it) } OneSignal.User.trackEvent(name, properties) call.resolve() } + private fun jsonObjectToMap(jsonObject: JSONObject): Map { + val map = mutableMapOf() + jsonObject.keys().forEach { key -> + map[key] = convertJsonValue(jsonObject.get(key)) + } + return map + } + + private fun jsonArrayToList(jsonArray: JSONArray): List { + val list = mutableListOf() + for (i in 0 until jsonArray.length()) { + list.add(convertJsonValue(jsonArray.get(i))) + } + return list + } + + private fun convertJsonValue(value: Any): Any? { + return when { + value == JSONObject.NULL -> null + value is JSONObject -> jsonObjectToMap(value) + value is JSONArray -> jsonArrayToList(value) + else -> value + } + } + // endregion // region Push Subscription @@ -356,7 +393,8 @@ class OneSignalCapacitorPlugin : Plugin(), @PluginMethod fun requestPermission(call: PluginCall) { val fallback = call.getBoolean("fallbackToSettings") ?: false - OneSignal.Notifications.requestPermission(fallback) { accepted -> + CoroutineScope(Dispatchers.Main).launch { + val accepted = OneSignal.Notifications.requestPermission(fallback) val ret = JSObject() ret.put("permission", accepted) call.resolve(ret) @@ -466,7 +504,7 @@ class OneSignalCapacitorPlugin : Plugin(), return } val triggers = mutableMapOf() - triggersObj.keys().forEach { key -> triggers[key] = triggersObj.getString(key) } + triggersObj.keys().forEach { key -> triggersObj.getString(key)?.let { triggers[key] = it } } OneSignal.InAppMessages.addTriggers(triggers) call.resolve() } @@ -549,8 +587,10 @@ class OneSignalCapacitorPlugin : Plugin(), @PluginMethod fun requestLocationPermission(call: PluginCall) { - OneSignal.Location.requestPermission() - call.resolve() + CoroutineScope(Dispatchers.Main).launch { + OneSignal.Location.requestPermission() + call.resolve() + } } @PluginMethod @@ -606,18 +646,21 @@ class OneSignalCapacitorPlugin : Plugin(), // region Observer Callbacks override fun onWillDisplay(event: INotificationWillDisplayEvent) { - val notificationId = event.notification.notificationId + val notificationId = event.notification.notificationId ?: return notificationWillDisplayCache[notificationId] = event event.preventDefault() - val ret = JSObject(event.notification.toJSONObject().toString()) + val ret = JSObject(event.notification.rawPayload) notifyListeners("notificationForegroundWillDisplay", ret) } override fun onClick(event: INotificationClickEvent) { if (bridge != null) { val ret = JSObject() - ret.put("result", JSObject(event.result.toJSONObject().toString())) - ret.put("notification", JSObject(event.notification.toJSONObject().toString())) + val clickResult = JSObject() + clickResult.put("actionId", event.result.actionId) + clickResult.put("url", event.result.url) + ret.put("result", clickResult) + ret.put("notification", JSObject(event.notification.rawPayload)) notifyListeners("notificationClick", ret) } else { pendingClickEvent = event @@ -649,12 +692,7 @@ class OneSignalCapacitorPlugin : Plugin(), } override fun onClick(event: IInAppMessageClickEvent) { - val urlTarget = when (event.result.urlTarget.ordinal) { - 0 -> "browser" - 1 -> "webview" - 2 -> "replacement" - else -> "browser" - } + val urlTarget = event.result.urlTarget?.toString() ?: "browser" val clickResult = JSObject() clickResult.put("closingMessage", event.result.closingMessage) diff --git a/examples/build.md b/examples/build.md new file mode 100644 index 0000000..d07667e --- /dev/null +++ b/examples/build.md @@ -0,0 +1,640 @@ +# OneSignal Capacitor Sample App - Build Guide + +This document extends the shared build guide with Capacitor-specific details. + +**Read the shared guide first:** +https://raw.githubusercontent.com/OneSignal/sdk-shared/refs/heads/main/demo/build.md + +Replace `{{PLATFORM}}` with `Capacitor` everywhere in that guide. Everything below either overrides or supplements sections from the shared guide. + +--- + +## Project Setup + +Create a new Capacitor + React project at `examples/demo/` (relative to the SDK repo root): + +```bash +mkdir -p examples/demo/src +cd examples/demo +bun init -y +bun add @capacitor/core @capacitor/cli @capacitor/ios @capacitor/android +bun add @capacitor/keyboard @capacitor/status-bar +bun add react react-dom @ionic/react @ionic/react-router ionicons react-icons +bun add react-router react-router-dom +bun add -d @vitejs/plugin-react @types/react @types/react-dom @types/react-router @types/react-router-dom typescript vite +bunx cap init "OneSignal Demo" com.onesignal.example --web-dir dist +bunx cap add ios +bunx cap add android +``` + +- TypeScript strict mode enabled +- React + Ionic React for component-based UI with React Router for navigation +- Separate section components per feature area, driven by a central `useOneSignal` hook +- Vite+ (`vite-plus`) with `@vitejs/plugin-react` for bundling, linting, and formatting; output to `dist/` (`webDir` for Capacitor) +- Support both Android and iOS + +App branding uses a custom header in `HomeScreen.tsx` with the OneSignal logo and "Capacitor" subtitle (no `IonToolbar` header). + +App icon generation uses `@capacitor/assets`. Place the OneSignal logo in `assets/icon-only.png`, then: + +```bash +bunx @capacitor/assets generate --ios --android --iconBackgroundColor '#ffffff' --splashBackgroundColor '#ffffff' +``` + +After generating, remove the adaptive icon files so Android uses the generated PNGs directly (the adaptive icon XMLs reference the default Capacitor foreground and override them): + +```bash +rm -rf android/app/src/main/res/mipmap-anydpi-v26 \ + android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml \ + android/app/src/main/res/drawable/ic_launcher_background.xml \ + android/app/src/main/res/values/ic_launcher_background.xml \ + android/app/src/main/res/mipmap-*/ic_launcher_foreground.png +``` + +Local SDK reference via packed tarball: + +```json +"onesignal-capacitor-plugin": "file:../../onesignal-capacitor-plugin.tgz" +``` + +A `setup.sh` script in `examples/` handles building, packing, installing, and running `cap sync` automatically. + +Package scripts: + +```json +{ + "scripts": { + "setup": "../setup.sh", + "preandroid": "bun run setup", + "preios": "bun run setup", + "android": "bash ../run-android.sh", + "ios": "bash ../run-ios.sh" + } +} +``` + +### Dependencies (package.json) + +Runtime: + +- `onesignal-capacitor-plugin` (local tarball) +- `@capacitor/core`, `@capacitor/ios`, `@capacitor/android` for Capacitor runtime +- `@capacitor/keyboard`, `@capacitor/status-bar` for native UI control +- `react`, `react-dom` for React +- `@ionic/react`, `@ionic/react-router` for Ionic React components and routing +- `react-router`, `react-router-dom` for page navigation +- `ionicons` for icon support +- `react-icons` for additional icons + +Dev: + +- `@capacitor/cli` for `cap sync`, `cap run`, etc. +- `vite-plus` for bundling, linting, and formatting +- `@vitejs/plugin-react` for JSX/TSX transform +- `@types/react`, `@types/react-dom`, `@types/react-router`, `@types/react-router-dom` +- `typescript` + +Vite+ config (`vite.config.ts`): + +```ts +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vite-plus'; + +export default defineConfig({ + plugins: [react()], + build: { + outDir: 'dist', + }, + fmt: { + singleQuote: true, + sortImports: { + enabled: true, + }, + }, + lint: { + options: { typeAware: true, typeCheck: true }, + }, +}); +``` + +Capacitor config (`capacitor.config.ts`): + +```ts +import type { CapacitorConfig } from '@capacitor/cli'; + +const config: CapacitorConfig = { + appId: 'com.onesignal.example', + appName: 'OneSignal Demo', + webDir: 'dist', + ios: { + handleApplicationNotifications: false, + }, +}; + +export default config; +``` + +The `handleApplicationNotifications: false` setting is required on iOS so that Capacitor does not intercept notifications before OneSignal's native delegate can process them. Without it, foreground notification display and lifecycle events will not work. + +### setup.sh Details + +The setup script performs: + +1. Builds the SDK from repo root (`bun run build`) +2. Packs to `onesignal-capacitor-plugin.tgz` +3. Reinstalls the tarball in the demo app +4. Builds the React web app (`vp build`) +5. Runs `bunx cap sync` + +### Run Scripts + +- `run-android.sh`: Lists connected ADB devices, prompts for selection if multiple, runs `bunx cap run android --target ` +- `run-ios.sh`: Lists booted iOS simulators, prompts for selection if multiple, runs `bunx cap run ios --target ` + +--- + +## Architecture + +The demo app follows a layered architecture with clear separation of concerns: + +### `useOneSignal` Hook (Central State Manager) + +All OneSignal SDK interactions and state are managed through a single `useOneSignal()` hook in `src/hooks/useOneSignal.ts`. This hook: + +- Initializes the SDK (via `OneSignal.initialize()`) +- Registers all event listeners (notifications, IAM, push subscription, user changes, permissions) +- Exposes reactive state (push subscription ID, permission status, aliases, tags, emails, etc.) +- Provides action methods (login, logout, send notification, add tag, etc.) +- Fetches user data from the REST API on user change events +- Handles cleanup of all listeners on unmount + +`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 +- `PreferencesService` (`src/services/PreferencesService.ts`) — Persists app settings (app ID, consent, IAM paused, location shared, external user ID) to `localStorage` +- `LogManager` (`src/services/LogManager.ts`) — Singleton logger with pub/sub; entries shown in the `LogView` component +- `TooltipHelper` (`src/services/TooltipHelper.ts`) — Fetches tooltip content from the shared `sdk-shared` repo for info modals + +### Models + +- `NotificationType` (`src/models/NotificationType.ts`) — Enum: `Simple`, `WithImage`, `WithSound`, `Custom` +- `UserData` (`src/models/UserData.ts`) — Interface + parser for REST API user response + +--- + +## OneSignal Repository (SDK API Mapping) + +Use the default export `OneSignal` from `onesignal-capacitor-plugin`: + +```typescript +import OneSignal, { LogLevel } from 'onesignal-capacitor-plugin'; +``` + +| Operation | SDK Call | +| --------------------------------- | ----------------------------------------------------------- | +| LoginUser(externalUserId) | `OneSignal.login(externalUserId)` | +| LogoutUser() | `OneSignal.logout()` | +| AddAlias(label, id) | `OneSignal.User.addAlias(label, id)` | +| AddAliases(aliases) | `OneSignal.User.addAliases(aliases)` | +| RemoveAlias(label) | `OneSignal.User.removeAlias(label)` | +| RemoveAliases(labels) | `OneSignal.User.removeAliases(labels)` | +| AddEmail(email) | `OneSignal.User.addEmail(email)` | +| RemoveEmail(email) | `OneSignal.User.removeEmail(email)` | +| AddSms(number) | `OneSignal.User.addSms(number)` | +| RemoveSms(number) | `OneSignal.User.removeSms(number)` | +| AddTag(key, value) | `OneSignal.User.addTag(key, value)` | +| AddTags(tags) | `OneSignal.User.addTags(tags)` | +| RemoveTag(key) | `OneSignal.User.removeTag(key)` | +| RemoveTags(keys) | `OneSignal.User.removeTags(keys)` | +| GetTags() | `await OneSignal.User.getTags()` | +| SetLanguage(language) | `OneSignal.User.setLanguage(language)` | +| AddTrigger(key, value) | `OneSignal.InAppMessages.addTrigger(key, value)` | +| AddTriggers(triggers) | `OneSignal.InAppMessages.addTriggers(triggers)` | +| RemoveTrigger(key) | `OneSignal.InAppMessages.removeTrigger(key)` | +| RemoveTriggers(keys) | `OneSignal.InAppMessages.removeTriggers(keys)` | +| ClearTriggers() | `OneSignal.InAppMessages.clearTriggers()` | +| GetPaused() | `await OneSignal.InAppMessages.getPaused()` | +| SetPaused(paused) | `OneSignal.InAppMessages.setPaused(paused)` | +| SendOutcome(name) | `OneSignal.Session.addOutcome(name)` | +| SendUniqueOutcome(name) | `OneSignal.Session.addUniqueOutcome(name)` | +| SendOutcomeWithValue(name, value) | `OneSignal.Session.addOutcomeWithValue(name, value)` | +| TrackEvent(name, properties) | `OneSignal.User.trackEvent(name, properties)` | +| GetPushSubscriptionId() | `await OneSignal.User.pushSubscription.getIdAsync()` | +| GetPushSubscriptionToken() | `await OneSignal.User.pushSubscription.getTokenAsync()` | +| IsPushOptedIn() | `await OneSignal.User.pushSubscription.getOptedInAsync()` | +| OptInPush() | `OneSignal.User.pushSubscription.optIn()` | +| OptOutPush() | `OneSignal.User.pushSubscription.optOut()` | +| ClearAllNotifications() | `OneSignal.Notifications.clearAll()` | +| RemoveNotification(id) | `OneSignal.Notifications.removeNotification(id)` | +| RemoveGroupedNotifications(id) | `OneSignal.Notifications.removeGroupedNotifications(id)` | +| HasPermission() | `await OneSignal.Notifications.hasPermission()` | +| RequestPermission(fallback) | `await OneSignal.Notifications.requestPermission(fallback)` | +| CanRequestPermission() | `await OneSignal.Notifications.canRequestPermission()` | +| SetLocationShared(shared) | `OneSignal.Location.setShared(shared)` | +| IsLocationShared() | `await OneSignal.Location.isShared()` | +| RequestLocationPermission() | `OneSignal.Location.requestPermission()` | +| SetConsentRequired(required) | `OneSignal.setConsentRequired(required)` | +| SetConsentGiven(granted) | `OneSignal.setConsentGiven(granted)` | +| GetExternalId() | `await OneSignal.User.getExternalId()` | +| GetOnesignalId() | `await OneSignal.User.getOnesignalId()` | +| SetLogLevel(level) | `OneSignal.Debug.setLogLevel(level)` | +| SetAlertLevel(level) | `OneSignal.Debug.setAlertLevel(level)` | + +### Live Activities (iOS only) + +| Operation | SDK Call | +| --------------------------------------------- | ------------------------------------------------------------------------ | +| SetupDefault(options) | `OneSignal.LiveActivities.setupDefault(options)` | +| StartDefault(activityId, attributes, content) | `OneSignal.LiveActivities.startDefault(activityId, attributes, content)` | +| Enter(activityId, token) | `OneSignal.LiveActivities.enter(activityId, token)` | +| Exit(activityId) | `OneSignal.LiveActivities.exit(activityId)` | +| SetPushToStartToken(activityType, token) | `OneSignal.LiveActivities.setPushToStartToken(activityType, token)` | +| RemovePushToStartToken(activityType) | `OneSignal.LiveActivities.removePushToStartToken(activityType)` | + +REST API client uses built-in `fetch`. + +--- + +## SDK Initialization & Observers + +All SDK initialization and event registration is handled inside `useOneSignal()` hook in a single `useEffect`: + +```typescript +import OneSignal, { LogLevel } from 'onesignal-capacitor-plugin'; + +// Inside useEffect in useOneSignal(): +OneSignal.Debug.setLogLevel(LogLevel.Verbose); +OneSignal.setConsentRequired(consentRequired); +OneSignal.setConsentGiven(consentGiven); +OneSignal.initialize(appId); + +OneSignal.LiveActivities.setupDefault({ + enablePushToStart: true, + enablePushToUpdate: true, +}); +``` + +Event listeners (addEventListener pattern, same API as React Native): + +```typescript +OneSignal.Notifications.addEventListener('click', (e) => { + log(`Notification click: ${e.notification.title ?? ''}`); +}); + +OneSignal.Notifications.addEventListener('foregroundWillDisplay', (e) => { + log(`foregroundWillDisplay: ${e.getNotification().title ?? ''}`); +}); + +OneSignal.Notifications.addEventListener('permissionChange', (granted) => { + log(`Permission changed: ${granted}`); +}); + +OneSignal.InAppMessages.addEventListener('click', (e) => { + log(`IAM click: ${e.result.actionId ?? 'unknown'}`); +}); +``` + +User and push subscription observers: + +```typescript +OneSignal.User.addEventListener('change', (e) => { + log(`User changed`); +}); + +OneSignal.User.pushSubscription.addEventListener('change', (e) => { + log(`Push sub changed: optedIn=${e.current.optedIn}`); +}); +``` + +All listeners are cleaned up in the `useEffect` return function via `removeEventListener`. + +Under the hood, `addEventListener` wraps Capacitor's `this._plugin.addListener(nativeEventName, handler)`. The SDK maps public event names to native event names: + +| Namespace | Public Event | Native Event | +| ----------------------- | ----------------------- | ----------------------------------- | +| `User` | `change` | `userStateChange` | +| `User.pushSubscription` | `change` | `pushSubscriptionChange` | +| `Notifications` | `click` | `notificationClick` | +| `Notifications` | `foregroundWillDisplay` | `notificationForegroundWillDisplay` | +| `Notifications` | `permissionChange` | `permissionChange` | +| `InAppMessages` | `click` | `inAppMessageClick` | +| `InAppMessages` | `willDisplay` | `inAppMessageWillDisplay` | +| `InAppMessages` | `didDisplay` | `inAppMessageDidDisplay` | +| `InAppMessages` | `willDismiss` | `inAppMessageWillDismiss` | +| `InAppMessages` | `didDismiss` | `inAppMessageDidDismiss` | + +--- + +## State Management + +### `useOneSignal` Hook + +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 +- **Effects** via `useEffect`: one-time SDK init + listener registration with full cleanup +- **Memoized callbacks** via `useCallback`: `fetchUserDataFromApi` for API-driven state refresh + +The hook returns a typed object (`UseOneSignalReturn`) with all state values and action methods. `HomeScreen` destructures this and passes slices to section components as props. + +### Persistence + +`PreferencesService` persists the following to `localStorage`: + +- App ID +- Consent required / consent given +- External user ID +- Location sharing +- IAM paused + +On init, `useOneSignal` reads these preferences and restores state accordingly. + +### Data Flow + +``` +useOneSignal (hook) + ├── OneSignalRepository (SDK calls + native guards) + │ └── OneSignalApiService (REST API: send notifications, fetch user) + ├── PreferencesService (localStorage persistence) + └── LogManager (pub/sub logging → LogView) +``` + +--- + +## Capacitor-Specific UI Details + +### React Entry (`main.tsx`) + +Render the root component with strict mode: + +```tsx +import React from 'react'; +import { createRoot } from 'react-dom/client'; + +import App from './App'; + +const container = document.getElementById('root'); +const root = createRoot(container!); +root.render( + + + , +); +``` + +### App Shell (`App.tsx`) + +Uses Ionic React Router for navigation between `HomeScreen` and `Secondary`: + +```tsx + + + + + + + + + + + + + + + +``` + +`App.tsx` also configures `StatusBar` (dark style) and `Keyboard` (hide accessory bar) on startup. + +### HomeScreen + +`HomeScreen` is the main page assembling all section components. It: + +- Calls `useOneSignal()` to get SDK state and actions +- Manages dialog state for modals (login, add alias, add tag, outcomes, etc.) +- Renders sections as props-driven components +- Renders modals conditionally based on `DialogState` discriminated union + +### Section Components + +Each feature area is a separate React component under `src/components/sections/`: + +- `AppSection` — App ID display, consent toggles +- `UserSection` — External user ID, login/logout +- `PushSection` — Push subscription ID, permission, push toggle +- `SendPushSection` — Send simple/image/sound/custom notifications, clear all +- `InAppSection` — IAM pause toggle +- `SendIamSection` — Send IAM triggers (top banner, bottom banner, center modal, full screen) +- `AliasesSection` — List aliases, add single/multiple +- `EmailsSection` — List emails, add/remove +- `SmsSection` — List SMS numbers, add/remove +- `TagsSection` — List tags, add single/multiple, remove selected +- `OutcomesSection` — Send outcomes (normal, unique, with value) +- `TriggersSection` — List triggers, add single/multiple, remove selected, clear all +- `TrackEventSection` — Track custom events with properties +- `LocationSection` — Location sharing toggle, request permission +- `LiveActivitySection` — Enter/exit live activities + +### Shared Components + +- `SectionCard` — Reusable wrapper using `IonList` with inset styling and info icon +- `ActionButton` — Styled button component +- `ToggleRow` — Label + toggle component +- `ListWidgets` — Key-value list display with remove actions +- `LoadingOverlay` — Full-screen loading indicator +- `LogView` — Scrollable log display subscribing to `LogManager` + +### Modals + +Under `src/components/modals/`: + +- `ModalShell` — Base modal wrapper +- `SingleInputModal` — Single text input (login, add email, add SMS) +- `PairInputModal` — Two-field input (add alias, add tag, add trigger) +- `MultiPairInputModal` — Dynamic list of key-value pairs +- `MultiSelectRemoveModal` — Checkbox list for bulk removal +- `OutcomeModal` — Outcome name + mode (normal/unique/value) +- `TrackEventModal` — Event name + dynamic properties +- `CustomNotificationModal` — Custom title + body +- `TooltipModal` — Info tooltip display + +### Log View + +- React component subscribing to `LogManager` singleton +- Displays timestamped log entries with level indicators +- Auto-scrolls to latest entry + +### Secondary Page + +A minimal second page (`src/pages/Secondary.tsx`) reachable via a "NEXT ACTIVITY" button on HomeScreen, testing navigation behavior with the SDK. + +### Accessibility (Appium) + +Use `id` props on Ionic React elements for test automation. + +--- + +## iOS Project Setup + +The iOS Xcode project includes extension targets: + +### Entitlements + +- `ios/App/App/App.entitlements` — push notification (`aps-environment`) + app groups + +### Notification Service Extension + +- `ios/App/OneSignalNotificationServiceExtension/NotificationService.swift` — forwards to `OneSignalExtension` for rich notification support +- `ios/App/OneSignalNotificationServiceExtension/Info.plist` — extension point `com.apple.usernotifications.service` + +### Podfile + +The Podfile includes the NSE target: + +```ruby +target 'App' do + capacitor_pods +end + +target 'OneSignalNotificationServiceExtension' do + pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0' +end +``` + +--- + +## Platform Config + +### Android + +```xml + + + +``` + +### iOS + +- `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`) + +### Custom Notification Sound + +Copy `vine_boom.wav` from [sdk-shared/assets](https://github.com/OneSignal/sdk-shared/tree/main/assets) and place in: + +- **Android**: `android/app/src/main/res/raw/vine_boom.wav` +- **iOS**: `ios/App/App/vine_boom.wav` (add to Xcode project as a bundle resource) + +--- + +## Key Files Structure + +``` +examples/ +├── setup.sh # Build SDK, pack, install, vite build, cap sync +├── run-android.sh # Device selection + cap run android +├── run-ios.sh # Simulator selection + cap run ios +├── build.md # This file +└── demo/ + ├── index.html # Minimal HTML shell with React root + ├── capacitor.config.ts + ├── vite.config.ts + ├── tsconfig.json + ├── package.json + ├── src/ + │ ├── main.tsx # React entry, StrictMode, render + │ ├── App.tsx # IonApp + IonReactRouter, StatusBar/Keyboard config + │ ├── vite-env.d.ts # Vite client types + │ ├── assets/ + │ │ └── onesignal_logo.svg + │ ├── hooks/ + │ │ └── useOneSignal.ts # Central SDK state + actions hook + │ ├── models/ + │ │ ├── NotificationType.ts + │ │ └── UserData.ts + │ ├── repositories/ + │ │ └── OneSignalRepository.ts # SDK wrapper with native guards + │ ├── services/ + │ │ ├── LogManager.ts # Pub/sub logger singleton + │ │ ├── OneSignalApiService.ts # REST API client singleton + │ │ ├── PreferencesService.ts # localStorage persistence + │ │ └── TooltipHelper.ts # Remote tooltip content + │ ├── pages/ + │ │ ├── HomeScreen.tsx # Main page assembling all sections + │ │ ├── HomeScreen.css + │ │ ├── Secondary.tsx # Minimal secondary page + │ │ └── Secondary.css + │ ├── components/ + │ │ ├── ActionButton.tsx + │ │ ├── ListWidgets.tsx + │ │ ├── LoadingOverlay.tsx + │ │ ├── LogView.tsx + │ │ ├── LogView.css + │ │ ├── SectionCard.tsx + │ │ ├── ToggleRow.tsx + │ │ ├── modals/ + │ │ │ ├── ModalShell.tsx + │ │ │ ├── SingleInputModal.tsx + │ │ │ ├── PairInputModal.tsx + │ │ │ ├── MultiPairInputModal.tsx + │ │ │ ├── MultiSelectRemoveModal.tsx + │ │ │ ├── OutcomeModal.tsx + │ │ │ ├── TrackEventModal.tsx + │ │ │ ├── CustomNotificationModal.tsx + │ │ │ └── TooltipModal.tsx + │ │ └── sections/ + │ │ ├── AppSection.tsx + │ │ ├── UserSection.tsx + │ │ ├── PushSection.tsx + │ │ ├── SendPushSection.tsx + │ │ ├── InAppSection.tsx + │ │ ├── SendIamSection.tsx + │ │ ├── AliasesSection.tsx + │ │ ├── EmailsSection.tsx + │ │ ├── SmsSection.tsx + │ │ ├── TagsSection.tsx + │ │ ├── OutcomesSection.tsx + │ │ ├── TriggersSection.tsx + │ │ ├── TrackEventSection.tsx + │ │ ├── LocationSection.tsx + │ │ └── LiveActivitySection.tsx + │ └── theme/ + │ └── variables.css + ├── dist/ # Vite build output (webDir for Capacitor) + ├── android/ # Capacitor Android project + └── ios/ # Capacitor iOS project + └── App/ + ├── App/ # Main app target + │ ├── App.entitlements # Push + app groups + │ ├── vine_boom.wav # Custom notification sound + │ └── ... + ├── OneSignalNotificationServiceExtension/ # NSE target + │ ├── NotificationService.swift + │ └── Info.plist + └── Podfile +``` + +--- + +## Capacitor Best Practices + +- **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 +- **`useEffect` cleanup** for all SDK event listeners +- **Vite+** (`vite-plus`) with `@vitejs/plugin-react` for bundling, linting, and formatting +- **`cap sync`** after every dependency change to push web assets and native plugins +- **Async getters** (`getIdAsync`, `hasPermission`, etc.) over deprecated sync properties +- **`handleApplicationNotifications: false`** in `capacitor.config.ts` so OneSignal controls notification lifecycle on iOS diff --git a/examples/demo_pods/.env.example b/examples/demo_pods/.env.example new file mode 100644 index 0000000..60dda71 --- /dev/null +++ b/examples/demo_pods/.env.example @@ -0,0 +1 @@ +VITE_ONESIGNAL_API_KEY=your_rest_api_key diff --git a/examples/demo_pods/android/.gitignore b/examples/demo_pods/android/.gitignore new file mode 100644 index 0000000..48354a3 --- /dev/null +++ b/examples/demo_pods/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_pods/android/app/.gitignore b/examples/demo_pods/android/app/.gitignore new file mode 100644 index 0000000..043df80 --- /dev/null +++ b/examples/demo_pods/android/app/.gitignore @@ -0,0 +1,2 @@ +/build/* +!/build/.npmkeep diff --git a/examples/demo_pods/android/app/build.gradle b/examples/demo_pods/android/app/build.gradle new file mode 100644 index 0000000..898b4f0 --- /dev/null +++ b/examples/demo_pods/android/app/build.gradle @@ -0,0 +1,54 @@ +apply plugin: 'com.android.application' + +android { + namespace = "com.onesignal.example" + compileSdk = rootProject.ext.compileSdkVersion + defaultConfig { + applicationId "com.onesignal.example" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + aaptOptions { + // 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 { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +repositories { + flatDir{ + dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" + implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" + implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" + implementation project(':capacitor-android') + testImplementation "junit:junit:$junitVersion" + androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" + androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" + implementation project(':capacitor-cordova-android-plugins') +} + +apply from: 'capacitor.build.gradle' + +try { + def servicesJSON = file('google-services.json') + if (servicesJSON.text) { + apply plugin: 'com.google.gms.google-services' + } +} catch(Exception e) { + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") +} diff --git a/examples/demo_pods/android/app/proguard-rules.pro b/examples/demo_pods/android/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/examples/demo_pods/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_pods/android/app/src/main/AndroidManifest.xml b/examples/demo_pods/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0914b39 --- /dev/null +++ b/examples/demo_pods/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo_pods/android/app/src/main/java/com/onesignal/example/MainActivity.java b/examples/demo_pods/android/app/src/main/java/com/onesignal/example/MainActivity.java new file mode 100644 index 0000000..2730476 --- /dev/null +++ b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-land-hdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-land-hdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-land-mdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-land-mdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-land-xhdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-land-xhdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-land-xxhdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-land-xxhdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-land-xxxhdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-land-xxxhdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-port-hdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-port-hdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-port-mdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-port-mdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-port-xhdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-port-xhdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-port-xxhdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-port-xxhdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable-port-xxxhdpi/splash.png b/examples/demo_pods/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_pods/android/app/src/main/res/drawable-port-xxxhdpi/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/drawable/splash.png b/examples/demo_pods/android/app/src/main/res/drawable/splash.png new file mode 100644 index 0000000..f7a6492 Binary files /dev/null and b/examples/demo_pods/android/app/src/main/res/drawable/splash.png differ diff --git a/examples/demo_pods/android/app/src/main/res/layout/activity_main.xml b/examples/demo_pods/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b5ad138 --- /dev/null +++ b/examples/demo_pods/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-ldpi/ic_launcher.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-ldpi/ic_launcher.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/examples/demo_pods/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/examples/demo_pods/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_pods/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/examples/demo_pods/android/app/src/main/res/raw/vine_boom.wav b/examples/demo_pods/android/app/src/main/res/raw/vine_boom.wav new file mode 100644 index 0000000..626bd5c Binary files /dev/null and b/examples/demo_pods/android/app/src/main/res/raw/vine_boom.wav differ diff --git a/examples/demo_pods/android/app/src/main/res/values/ic_launcher_background.xml b/examples/demo_pods/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..c5d5899 --- /dev/null +++ b/examples/demo_pods/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_pods/android/app/src/main/res/values/strings.xml b/examples/demo_pods/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..0fce961 --- /dev/null +++ b/examples/demo_pods/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_pods/android/app/src/main/res/values/styles.xml b/examples/demo_pods/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..be874e5 --- /dev/null +++ b/examples/demo_pods/android/app/src/main/res/values/styles.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/examples/demo_pods/android/app/src/main/res/xml/file_paths.xml b/examples/demo_pods/android/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..bd0c4d8 --- /dev/null +++ b/examples/demo_pods/android/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/demo_pods/android/build.gradle b/examples/demo_pods/android/build.gradle new file mode 100644 index 0000000..5ac3595 --- /dev/null +++ b/examples/demo_pods/android/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '2.1.20' + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.13.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.google.gms:google-services:4.4.4' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +apply from: "variables.gradle" + +allprojects { + repositories { + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/examples/demo_pods/android/capacitor.settings.gradle b/examples/demo_pods/android/capacitor.settings.gradle new file mode 100644 index 0000000..26401ea --- /dev/null +++ b/examples/demo_pods/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_pods/android/gradle.properties b/examples/demo_pods/android/gradle.properties new file mode 100644 index 0000000..2e87c52 --- /dev/null +++ b/examples/demo_pods/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_pods/android/gradle/wrapper/gradle-wrapper.jar b/examples/demo_pods/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..1b33c55 Binary files /dev/null and b/examples/demo_pods/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/demo_pods/android/gradle/wrapper/gradle-wrapper.properties b/examples/demo_pods/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7705927 --- /dev/null +++ b/examples/demo_pods/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_pods/android/gradlew b/examples/demo_pods/android/gradlew new file mode 100755 index 0000000..23d15a9 --- /dev/null +++ b/examples/demo_pods/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_pods/android/gradlew.bat b/examples/demo_pods/android/gradlew.bat new file mode 100644 index 0000000..5eed7ee --- /dev/null +++ b/examples/demo_pods/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_pods/android/settings.gradle b/examples/demo_pods/android/settings.gradle new file mode 100644 index 0000000..3b4431d --- /dev/null +++ b/examples/demo_pods/android/settings.gradle @@ -0,0 +1,5 @@ +include ':app' +include ':capacitor-cordova-android-plugins' +project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') + +apply from: 'capacitor.settings.gradle' \ No newline at end of file diff --git a/examples/demo_pods/android/variables.gradle b/examples/demo_pods/android/variables.gradle new file mode 100644 index 0000000..ee4ba41 --- /dev/null +++ b/examples/demo_pods/android/variables.gradle @@ -0,0 +1,16 @@ +ext { + minSdkVersion = 24 + compileSdkVersion = 36 + targetSdkVersion = 36 + androidxActivityVersion = '1.11.0' + androidxAppCompatVersion = '1.7.1' + androidxCoordinatorLayoutVersion = '1.3.0' + androidxCoreVersion = '1.17.0' + androidxFragmentVersion = '1.8.9' + coreSplashScreenVersion = '1.2.0' + androidxWebkitVersion = '1.14.0' + junitVersion = '4.13.2' + androidxJunitVersion = '1.3.0' + androidxEspressoCoreVersion = '3.7.0' + cordovaAndroidVersion = '14.0.1' +} \ No newline at end of file diff --git a/examples/demo_pods/assets/icon-only.png b/examples/demo_pods/assets/icon-only.png new file mode 100644 index 0000000..4ff809f Binary files /dev/null and b/examples/demo_pods/assets/icon-only.png differ diff --git a/examples/demo_pods/capacitor.config.ts b/examples/demo_pods/capacitor.config.ts new file mode 100644 index 0000000..6ae21c8 --- /dev/null +++ b/examples/demo_pods/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_pods/index.html b/examples/demo_pods/index.html new file mode 100644 index 0000000..195b310 --- /dev/null +++ b/examples/demo_pods/index.html @@ -0,0 +1,15 @@ + + + + + + OneSignal Capacitor Demo + + +
+ + + diff --git a/examples/demo_pods/ios/.gitignore b/examples/demo_pods/ios/.gitignore new file mode 100644 index 0000000..f470299 --- /dev/null +++ b/examples/demo_pods/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_pods/ios/App/App.xcodeproj/project.pbxproj b/examples/demo_pods/ios/App/App.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e299498 --- /dev/null +++ b/examples/demo_pods/ios/App/App.xcodeproj/project.pbxproj @@ -0,0 +1,871 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 70; + objects = { + +/* Begin PBXBuildFile section */ + 2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; }; + 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 */; }; + 95615607459738CFF12024C4 /* Pods_OneSignalNotificationServiceExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D191B1D10181F15D1D7403B /* Pods_OneSignalNotificationServiceExtension.framework */; }; + 96B4B0B657CB38123946AFB8 /* Pods_OneSignalWidgetExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 329C603DA4E0E173315C0022 /* Pods_OneSignalWidgetExtension.framework */; }; + A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; }; + E8C8D2F92F804D97006581CB /* OneSignalNotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = E8C8D2F22F804D97006581CB /* OneSignalNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + E8C8D3922F807080006581CB /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8C8D3912F807080006581CB /* WidgetKit.framework */; }; + E8C8D3942F807080006581CB /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8C8D3932F807080006581CB /* SwiftUI.framework */; }; + E8C8D3A12F807082006581CB /* OneSignalWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = E8C8D3902F807080006581CB /* OneSignalWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + E8D1A0012FA00001006581CB /* vine_boom.wav in Resources */ = {isa = PBXBuildFile; fileRef = E8D1A0002FA00001006581CB /* vine_boom.wav */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + E8C8D2F72F804D97006581CB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 504EC2FC1FED79650016851F /* Project object */; + proxyType = 1; + remoteGlobalIDString = E8C8D2F12F804D97006581CB; + remoteInfo = OneSignalNotificationServiceExtension; + }; + E8C8D39F2F807082006581CB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 504EC2FC1FED79650016851F /* Project object */; + proxyType = 1; + remoteGlobalIDString = E8C8D38F2F807080006581CB; + remoteInfo = OneSignalWidgetExtension; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + E8C8D2FE2F804D97006581CB /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + E8C8D2F92F804D97006581CB /* OneSignalNotificationServiceExtension.appex in Embed Foundation Extensions */, + E8C8D3A12F807082006581CB /* 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 = ""; }; + 329C603DA4E0E173315C0022 /* Pods_OneSignalWidgetExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OneSignalWidgetExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4B2607CC29A855A7CD1F906A /* Pods-OneSignalNotificationServiceExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.debug.xcconfig"; 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 = ""; }; + 6D191B1D10181F15D1D7403B /* Pods_OneSignalNotificationServiceExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OneSignalNotificationServiceExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 72AFAF589B39A124F11D132D /* Pods-OneSignalWidgetExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalWidgetExtension.release.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalWidgetExtension/Pods-OneSignalWidgetExtension.release.xcconfig"; sourceTree = ""; }; + AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = ""; }; + DE734FBDBF09FBBA6D25AB98 /* Pods-OneSignalNotificationServiceExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release.xcconfig"; sourceTree = ""; }; + E8C8D2ED2F7F4BD9006581CB /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = ""; }; + E8C8D2F22F804D97006581CB /* OneSignalNotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OneSignalNotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + E8C8D3902F807080006581CB /* OneSignalWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OneSignalWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + E8C8D3912F807080006581CB /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; + E8C8D3932F807080006581CB /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; + E8D1A0002FA00001006581CB /* vine_boom.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = vine_boom.wav; sourceTree = ""; }; + F00A922F300D5D4E6C58E90E /* Pods-OneSignalWidgetExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalWidgetExtension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalWidgetExtension/Pods-OneSignalWidgetExtension.debug.xcconfig"; sourceTree = ""; }; + FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + E8C8D2FA2F804D97006581CB /* Exceptions for "OneSignalNotificationServiceExtension" folder in "OneSignalNotificationServiceExtension" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = E8C8D2F12F804D97006581CB /* OneSignalNotificationServiceExtension */; + }; + E8C8D3A42F807082006581CB /* Exceptions for "OneSignalWidget" folder in "OneSignalWidgetExtension" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = E8C8D38F2F807080006581CB /* OneSignalWidgetExtension */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + E8C8D2F32F804D97006581CB /* OneSignalNotificationServiceExtension */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + E8C8D2FA2F804D97006581CB /* Exceptions for "OneSignalNotificationServiceExtension" folder in "OneSignalNotificationServiceExtension" target */, + ); + explicitFileTypes = { + }; + explicitFolders = ( + ); + path = OneSignalNotificationServiceExtension; + sourceTree = ""; + }; + E8C8D3952F807080006581CB /* OneSignalWidget */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + E8C8D3A42F807082006581CB /* Exceptions for "OneSignalWidget" folder in "OneSignalWidgetExtension" target */, + ); + explicitFileTypes = { + }; + explicitFolders = ( + ); + path = OneSignalWidget; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 504EC3011FED79650016851F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E8C8D2EF2F804D97006581CB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 95615607459738CFF12024C4 /* Pods_OneSignalNotificationServiceExtension.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E8C8D38D2F807080006581CB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E8C8D3942F807080006581CB /* SwiftUI.framework in Frameworks */, + E8C8D3922F807080006581CB /* WidgetKit.framework in Frameworks */, + 96B4B0B657CB38123946AFB8 /* Pods_OneSignalWidgetExtension.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */ = { + isa = PBXGroup; + children = ( + AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */, + 6D191B1D10181F15D1D7403B /* Pods_OneSignalNotificationServiceExtension.framework */, + E8C8D3912F807080006581CB /* WidgetKit.framework */, + E8C8D3932F807080006581CB /* SwiftUI.framework */, + 329C603DA4E0E173315C0022 /* Pods_OneSignalWidgetExtension.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 504EC2FB1FED79650016851F = { + isa = PBXGroup; + children = ( + 504EC3061FED79650016851F /* App */, + E8C8D2F32F804D97006581CB /* OneSignalNotificationServiceExtension */, + E8C8D3952F807080006581CB /* OneSignalWidget */, + 504EC3051FED79650016851F /* Products */, + 7F8756D8B27F46E3366F6CEA /* Pods */, + 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */, + ); + sourceTree = ""; + }; + 504EC3051FED79650016851F /* Products */ = { + isa = PBXGroup; + children = ( + 504EC3041FED79650016851F /* App.app */, + E8C8D2F22F804D97006581CB /* OneSignalNotificationServiceExtension.appex */, + E8C8D3902F807080006581CB /* OneSignalWidgetExtension.appex */, + ); + name = Products; + sourceTree = ""; + }; + 504EC3061FED79650016851F /* App */ = { + isa = PBXGroup; + children = ( + E8C8D2ED2F7F4BD9006581CB /* 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 */, + E8D1A0002FA00001006581CB /* vine_boom.wav */, + ); + path = App; + sourceTree = ""; + }; + 7F8756D8B27F46E3366F6CEA /* Pods */ = { + isa = PBXGroup; + children = ( + FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */, + AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */, + 4B2607CC29A855A7CD1F906A /* Pods-OneSignalNotificationServiceExtension.debug.xcconfig */, + DE734FBDBF09FBBA6D25AB98 /* Pods-OneSignalNotificationServiceExtension.release.xcconfig */, + F00A922F300D5D4E6C58E90E /* Pods-OneSignalWidgetExtension.debug.xcconfig */, + 72AFAF589B39A124F11D132D /* Pods-OneSignalWidgetExtension.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 504EC3031FED79650016851F /* App */ = { + isa = PBXNativeTarget; + buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */; + buildPhases = ( + 6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */, + 504EC3001FED79650016851F /* Sources */, + 504EC3011FED79650016851F /* Frameworks */, + 504EC3021FED79650016851F /* Resources */, + 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */, + E8C8D2FE2F804D97006581CB /* Embed Foundation Extensions */, + ); + buildRules = ( + ); + dependencies = ( + E8C8D2F82F804D97006581CB /* PBXTargetDependency */, + E8C8D3A02F807082006581CB /* PBXTargetDependency */, + ); + name = App; + productName = App; + productReference = 504EC3041FED79650016851F /* App.app */; + productType = "com.apple.product-type.application"; + }; + E8C8D2F12F804D97006581CB /* OneSignalNotificationServiceExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = E8C8D2FB2F804D97006581CB /* Build configuration list for PBXNativeTarget "OneSignalNotificationServiceExtension" */; + buildPhases = ( + E754FB6D102CD083AC6E028D /* [CP] Check Pods Manifest.lock */, + E8C8D2EE2F804D97006581CB /* Sources */, + E8C8D2EF2F804D97006581CB /* Frameworks */, + E8C8D2F02F804D97006581CB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + E8C8D2F32F804D97006581CB /* OneSignalNotificationServiceExtension */, + ); + name = OneSignalNotificationServiceExtension; + productName = OneSignalNotificationServiceExtension; + productReference = E8C8D2F22F804D97006581CB /* OneSignalNotificationServiceExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; + E8C8D38F2F807080006581CB /* OneSignalWidgetExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = E8C8D3A52F807082006581CB /* Build configuration list for PBXNativeTarget "OneSignalWidgetExtension" */; + buildPhases = ( + 1B287FF1A6FFBA8DE1D92B2E /* [CP] Check Pods Manifest.lock */, + E8C8D38C2F807080006581CB /* Sources */, + E8C8D38D2F807080006581CB /* Frameworks */, + E8C8D38E2F807080006581CB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + E8C8D3952F807080006581CB /* OneSignalWidget */, + ); + name = OneSignalWidgetExtension; + productName = OneSignalWidgetExtension; + productReference = E8C8D3902F807080006581CB /* OneSignalWidgetExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 504EC2FC1FED79650016851F /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 2620; + LastUpgradeCheck = 920; + TargetAttributes = { + 504EC3031FED79650016851F = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + }; + E8C8D2F12F804D97006581CB = { + CreatedOnToolsVersion = 26.2; + }; + E8C8D38F2F807080006581CB = { + CreatedOnToolsVersion = 26.2; + }; + }; + }; + buildConfigurationList = 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 504EC2FB1FED79650016851F; + productRefGroup = 504EC3051FED79650016851F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 504EC3031FED79650016851F /* App */, + E8C8D2F12F804D97006581CB /* OneSignalNotificationServiceExtension */, + E8C8D38F2F807080006581CB /* 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 */, + E8D1A0012FA00001006581CB /* vine_boom.wav in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E8C8D2F02F804D97006581CB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E8C8D38E2F807080006581CB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 1B287FF1A6FFBA8DE1D92B2E /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-OneSignalWidgetExtension-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-App-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + E754FB6D102CD083AC6E028D /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-OneSignalNotificationServiceExtension-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 504EC3001FED79650016851F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3081FED79650016851F /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E8C8D2EE2F804D97006581CB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E8C8D38C2F807080006581CB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + E8C8D2F82F804D97006581CB /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = E8C8D2F12F804D97006581CB /* OneSignalNotificationServiceExtension */; + targetProxy = E8C8D2F72F804D97006581CB /* PBXContainerItemProxy */; + }; + E8C8D3A02F807082006581CB /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = E8C8D38F2F807080006581CB /* OneSignalWidgetExtension */; + targetProxy = E8C8D39F2F807082006581CB /* 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; + 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 = FC68EB0AF532CFC21C3344DD /* Pods-App.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; + baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.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; + 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; + }; + E8C8D2FC2F804D97006581CB /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4B2607CC29A855A7CD1F906A /* Pods-OneSignalNotificationServiceExtension.debug.xcconfig */; + 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.OneSignalNotificationServiceExtensionCap; + 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; + }; + E8C8D2FD2F804D97006581CB /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = DE734FBDBF09FBBA6D25AB98 /* Pods-OneSignalNotificationServiceExtension.release.xcconfig */; + 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.OneSignalNotificationServiceExtensionCap; + 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; + }; + E8C8D3A22F807082006581CB /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F00A922F300D5D4E6C58E90E /* Pods-OneSignalWidgetExtension.debug.xcconfig */; + 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.OneSignalWidget; + 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; + }; + E8C8D3A32F807082006581CB /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 72AFAF589B39A124F11D132D /* Pods-OneSignalWidgetExtension.release.xcconfig */; + 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.OneSignalWidget; + 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; + }; + E8C8D2FB2F804D97006581CB /* Build configuration list for PBXNativeTarget "OneSignalNotificationServiceExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E8C8D2FC2F804D97006581CB /* Debug */, + E8C8D2FD2F804D97006581CB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E8C8D3A52F807082006581CB /* Build configuration list for PBXNativeTarget "OneSignalWidgetExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E8C8D3A22F807082006581CB /* Debug */, + E8C8D3A32F807082006581CB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 504EC2FC1FED79650016851F /* Project object */; +} diff --git a/examples/demo_pods/ios/App/App.xcworkspace/contents.xcworkspacedata b/examples/demo_pods/ios/App/App.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..b301e82 --- /dev/null +++ b/examples/demo_pods/ios/App/App.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/examples/demo_pods/ios/App/App/App.entitlements b/examples/demo_pods/ios/App/App/App.entitlements new file mode 100644 index 0000000..3446364 --- /dev/null +++ b/examples/demo_pods/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_pods/ios/App/App/AppDelegate.swift b/examples/demo_pods/ios/App/App/AppDelegate.swift new file mode 100644 index 0000000..c3cd83b --- /dev/null +++ b/examples/demo_pods/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_pods/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png b/examples/demo_pods/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png new file mode 100644 index 0000000..ed5c8d8 Binary files /dev/null and b/examples/demo_pods/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png differ diff --git a/examples/demo_pods/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/demo_pods/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..5e294d5 --- /dev/null +++ b/examples/demo_pods/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images": [ + { + "idiom": "universal", + "size": "1024x1024", + "filename": "AppIcon-512@2x.png", + "platform": "ios" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/examples/demo_pods/ios/App/App/Assets.xcassets/Contents.json b/examples/demo_pods/ios/App/App/Assets.xcassets/Contents.json new file mode 100644 index 0000000..97a8662 --- /dev/null +++ b/examples/demo_pods/ios/App/App/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "version": 1, + "author": "xcode" + } +} diff --git a/examples/demo_pods/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json b/examples/demo_pods/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json new file mode 100644 index 0000000..b781492 --- /dev/null +++ b/examples/demo_pods/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_pods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png b/examples/demo_pods/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_pods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png differ diff --git a/examples/demo_pods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png b/examples/demo_pods/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_pods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png differ diff --git a/examples/demo_pods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png b/examples/demo_pods/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_pods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png differ diff --git a/examples/demo_pods/ios/App/App/Base.lproj/LaunchScreen.storyboard b/examples/demo_pods/ios/App/App/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..e7ae5d7 --- /dev/null +++ b/examples/demo_pods/ios/App/App/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo_pods/ios/App/App/Base.lproj/Main.storyboard b/examples/demo_pods/ios/App/App/Base.lproj/Main.storyboard new file mode 100644 index 0000000..b44df7b --- /dev/null +++ b/examples/demo_pods/ios/App/App/Base.lproj/Main.storyboard @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo_pods/ios/App/App/Info.plist b/examples/demo_pods/ios/App/App/Info.plist new file mode 100644 index 0000000..f6f4839 --- /dev/null +++ b/examples/demo_pods/ios/App/App/Info.plist @@ -0,0 +1,59 @@ + + + + + NSSupportsLiveActivities + + 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 + + NSLocationWhenInUseUsageDescription + This app uses your location to personalize notifications and content. + NSLocationAlwaysAndWhenInUseUsageDescription + This app uses your location to personalize notifications and content, even in the background. + + diff --git a/examples/demo_pods/ios/App/App/vine_boom.wav b/examples/demo_pods/ios/App/App/vine_boom.wav new file mode 100644 index 0000000..626bd5c Binary files /dev/null and b/examples/demo_pods/ios/App/App/vine_boom.wav differ diff --git a/examples/demo_pods/ios/App/OneSignalNotificationServiceExtension/Info.plist b/examples/demo_pods/ios/App/OneSignalNotificationServiceExtension/Info.plist new file mode 100644 index 0000000..57421eb --- /dev/null +++ b/examples/demo_pods/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_pods/ios/App/OneSignalNotificationServiceExtension/NotificationService.swift b/examples/demo_pods/ios/App/OneSignalNotificationServiceExtension/NotificationService.swift new file mode 100644 index 0000000..ab391a3 --- /dev/null +++ b/examples/demo_pods/ios/App/OneSignalNotificationServiceExtension/NotificationService.swift @@ -0,0 +1,32 @@ +import UserNotifications +import OneSignalExtension + +class NotificationService: UNNotificationServiceExtension { + var contentHandler: ((UNNotificationContent) -> Void)? + var receivedRequest: UNNotificationRequest! + var bestAttemptContent: UNMutableNotificationContent? + + // Note this extension only runs when `mutable_content` is set + // Setting an attachment or action buttons automatically sets the property to true + 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 the 2 lines below to check this extension is executing +// print("Running NotificationServiceExtension") +// bestAttemptContent.body = "[Modified] " + bestAttemptContent.body + + OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler) + } + } + + override func serviceExtensionTimeWillExpire() { + // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. + if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { + OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent) + contentHandler(bestAttemptContent) + } + } +} diff --git a/examples/demo_pods/ios/App/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements b/examples/demo_pods/ios/App/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements new file mode 100644 index 0000000..c70461e --- /dev/null +++ b/examples/demo_pods/ios/App/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.onesignal.example.onesignal + + + diff --git a/examples/demo_pods/ios/App/OneSignalWidget/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/demo_pods/ios/App/OneSignalWidget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..0afb3cf --- /dev/null +++ b/examples/demo_pods/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_pods/ios/App/OneSignalWidget/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/demo_pods/ios/App/OneSignalWidget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..c70a5bf --- /dev/null +++ b/examples/demo_pods/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_pods/ios/App/OneSignalWidget/Assets.xcassets/Contents.json b/examples/demo_pods/ios/App/OneSignalWidget/Assets.xcassets/Contents.json new file mode 100644 index 0000000..74d6a72 --- /dev/null +++ b/examples/demo_pods/ios/App/OneSignalWidget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/examples/demo_pods/ios/App/OneSignalWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json b/examples/demo_pods/ios/App/OneSignalWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 0000000..0afb3cf --- /dev/null +++ b/examples/demo_pods/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_pods/ios/App/OneSignalWidget/Info.plist b/examples/demo_pods/ios/App/OneSignalWidget/Info.plist new file mode 100644 index 0000000..0f118fb --- /dev/null +++ b/examples/demo_pods/ios/App/OneSignalWidget/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/examples/demo_pods/ios/App/OneSignalWidget/OneSignalWidgetBundle.swift b/examples/demo_pods/ios/App/OneSignalWidget/OneSignalWidgetBundle.swift new file mode 100644 index 0000000..1344cd7 --- /dev/null +++ b/examples/demo_pods/ios/App/OneSignalWidget/OneSignalWidgetBundle.swift @@ -0,0 +1,16 @@ +// +// OneSignalWidgetBundle.swift +// OneSignalWidget +// +// Created by Fadi George on 4/3/26. +// + +import WidgetKit +import SwiftUI + +@main +struct OneSignalWidgetBundle: WidgetBundle { + var body: some Widget { + OneSignalWidgetLiveActivity() + } +} diff --git a/examples/demo_pods/ios/App/OneSignalWidget/OneSignalWidgetLiveActivity.swift b/examples/demo_pods/ios/App/OneSignalWidget/OneSignalWidgetLiveActivity.swift new file mode 100644 index 0000000..0ade610 --- /dev/null +++ b/examples/demo_pods/ios/App/OneSignalWidget/OneSignalWidgetLiveActivity.swift @@ -0,0 +1,143 @@ + +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_pods/ios/App/Podfile b/examples/demo_pods/ios/App/Podfile new file mode 100644 index 0000000..78fb7d5 --- /dev/null +++ b/examples/demo_pods/ios/App/Podfile @@ -0,0 +1,34 @@ +require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers' + +platform :ios, '15.0' +use_frameworks! + +# workaround to avoid Xcode caching of Pods that requires +# Product -> Clean Build Folder after new Cordova plugins installed +# Requires CocoaPods 1.6 or newer +install! 'cocoapods', :disable_input_output_paths => true + +def capacitor_pods + pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' + pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' + pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard' + pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar' + pod 'OnesignalCapacitorPlugin', :path => '../../node_modules/onesignal-capacitor-plugin' +end + +target 'App' do + capacitor_pods + # Add your Pods here +end + +post_install do |installer| + assertDeploymentTarget(installer) +end + +target 'OneSignalNotificationServiceExtension' do + pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0' +end + +target 'OneSignalWidgetExtension' do + pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0' +end diff --git a/examples/demo_pods/package.json b/examples/demo_pods/package.json new file mode 100644 index 0000000..ceead76 --- /dev/null +++ b/examples/demo_pods/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/Pods ios/App/build", + "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_pods/src/App.tsx b/examples/demo_pods/src/App.tsx new file mode 100644 index 0000000..d8a0488 --- /dev/null +++ b/examples/demo_pods/src/App.tsx @@ -0,0 +1,52 @@ +import { Capacitor } from '@capacitor/core'; +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'; + +if (Capacitor.isNativePlatform()) { + StatusBar.setStyle({ style: Style.Dark }).catch(() => {}); +} + +setupIonicReact(); + +const App: React.FC = () => ( + + + + + + + + + + + + + + + +); + +export default App; diff --git a/examples/demo_pods/src/assets/onesignal_logo.svg b/examples/demo_pods/src/assets/onesignal_logo.svg new file mode 100644 index 0000000..79bfe39 --- /dev/null +++ b/examples/demo_pods/src/assets/onesignal_logo.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo_pods/src/components/ActionButton.tsx b/examples/demo_pods/src/components/ActionButton.tsx new file mode 100644 index 0000000..b91f81e --- /dev/null +++ b/examples/demo_pods/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 }) => { + 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; + + return ( +
+ {items.length ? ( + <> + {displayItems.map((item) => ( +
+ {item} + {onRemove ? ( + + ) : null} +
+ ))} + {!showAll && hiddenCount > 0 && ( + + )} + + ) : ( + + )} +
+ ); +}; diff --git a/examples/demo_pods/src/components/LoadingOverlay.tsx b/examples/demo_pods/src/components/LoadingOverlay.tsx new file mode 100644 index 0000000..c2b4439 --- /dev/null +++ b/examples/demo_pods/src/components/LoadingOverlay.tsx @@ -0,0 +1,15 @@ +import { IonSpinner } from '@ionic/react'; +import type { FC } from 'react'; + +interface LoadingOverlayProps { + visible: boolean; +} + +const LoadingOverlay: FC = ({ visible }) => + visible ? ( +
+ +
+ ) : null; + +export default LoadingOverlay; diff --git a/examples/demo_pods/src/components/LogView.css b/examples/demo_pods/src/components/LogView.css new file mode 100644 index 0000000..2a84263 --- /dev/null +++ b/examples/demo_pods/src/components/LogView.css @@ -0,0 +1,81 @@ +.logview-panel { + position: sticky; + top: var(--demo-header-height, 84px); + z-index: 20; + background: var(--os-log-background); +} + +.logview-header { + display: flex; + align-items: center; + gap: 8px; + padding: 12px 16px; + cursor: pointer; +} + +.logview-header strong { + font-size: var(--font-size-label-small); + font-weight: 700; + color: #fff; +} + +.logview-count { + font-size: var(--font-size-label-small); + color: var(--os-grey-500); + margin-right: auto; +} + +.logview-header .icon-btn { + font-size: 18px; + color: var(--os-grey-500); +} + +.logview-body { + height: 100px; + overflow-x: auto; + overflow-y: auto; + padding: 0 12px 4px; +} + +.logview-row { + display: flex; + gap: 4px; + white-space: nowrap; + font-size: var(--font-size-label-small); + font-family: monospace; + line-height: 1.4; + padding: 1px 0; +} + +.log-time { + color: var(--os-log-timestamp); +} + +.log-level { + font-weight: 700; +} + +.log-level-d { + color: var(--os-log-debug); +} +.log-level-i { + color: var(--os-log-info); +} +.log-level-w { + color: var(--os-log-warn); +} +.log-level-e { + color: var(--os-log-error); +} + +.log-text { + color: #fff; +} + +.logview-empty { + color: var(--os-grey-500); + font-size: var(--font-size-label-small); + font-family: monospace; + padding: 12px 0; + text-align: center; +} diff --git a/examples/demo_pods/src/components/LogView.tsx b/examples/demo_pods/src/components/LogView.tsx new file mode 100644 index 0000000..d1a0ca1 --- /dev/null +++ b/examples/demo_pods/src/components/LogView.tsx @@ -0,0 +1,89 @@ +import type { FC } from 'react'; +import { useEffect, useState } from 'react'; +import { MdDelete, MdKeyboardArrowDown, MdKeyboardArrowUp } from 'react-icons/md'; + +import type { LogEntry } from '../services/LogManager'; +import LogManager from '../services/LogManager'; + +import './LogView.css'; + +const manager = LogManager.getInstance(); + +const LogView: FC = () => { + const [entries, setEntries] = useState([]); + const [collapsed, setCollapsed] = useState(false); + + useEffect(() => { + return manager.subscribe((entry) => { + if (entry) { + setEntries((prev) => [entry, ...prev]); + } else { + setEntries([]); + } + }); + }, []); + + return ( +
+
setCollapsed((value) => !value)} + > + LOGS + + ({entries.length}) + + {entries.length > 0 && ( + + )} + + {collapsed ? : } + +
+ {!collapsed ? ( +
+ {entries.length ? ( + entries.map((entry, index) => ( +
+ + {entry.timestamp} + + + {entry.level} + + + {entry.tag}: {entry.message} + +
+ )) + ) : ( +
+ No logs yet +
+ )} +
+ ) : null} +
+ ); +}; + +export default LogView; diff --git a/examples/demo_pods/src/components/SectionCard.tsx b/examples/demo_pods/src/components/SectionCard.tsx new file mode 100644 index 0000000..757bb26 --- /dev/null +++ b/examples/demo_pods/src/components/SectionCard.tsx @@ -0,0 +1,24 @@ +import type { FC, ReactNode } from 'react'; +import { MdInfoOutline } from 'react-icons/md'; + +interface SectionCardProps { + title: string; + onInfoTap?: () => void; + children: ReactNode; +} + +const SectionCard: FC = ({ title, onInfoTap, children }) => ( +
+
+

{title}

+ {onInfoTap ? ( + + ) : null} +
+ {children} +
+); + +export default SectionCard; diff --git a/examples/demo_pods/src/components/ToggleRow.tsx b/examples/demo_pods/src/components/ToggleRow.tsx new file mode 100644 index 0000000..eb8f0fd --- /dev/null +++ b/examples/demo_pods/src/components/ToggleRow.tsx @@ -0,0 +1,21 @@ +import { IonToggle } from '@ionic/react'; +import type { FC } from 'react'; + +interface ToggleRowProps { + label: string; + description?: string; + checked: boolean; + onToggle: (checked: boolean) => void; +} + +const ToggleRow: FC = ({ label, description, checked, onToggle }) => ( +
+
+
{label}
+ {description ?
{description}
: null} +
+ onToggle(event.detail.checked)} /> +
+); + +export default ToggleRow; diff --git a/examples/demo_pods/src/components/modals/CustomNotificationModal.tsx b/examples/demo_pods/src/components/modals/CustomNotificationModal.tsx new file mode 100644 index 0000000..1672213 --- /dev/null +++ b/examples/demo_pods/src/components/modals/CustomNotificationModal.tsx @@ -0,0 +1,58 @@ +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" + /> + setBody(event.target.value)} placeholder="Body" /> +
+ + +
+
+
+ ); +}; + +export default CustomNotificationModal; diff --git a/examples/demo_pods/src/components/modals/ModalShell.tsx b/examples/demo_pods/src/components/modals/ModalShell.tsx new file mode 100644 index 0000000..a095074 --- /dev/null +++ b/examples/demo_pods/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_pods/src/components/modals/MultiPairInputModal.tsx b/examples/demo_pods/src/components/modals/MultiPairInputModal.tsx new file mode 100644 index 0000000..c6dc4d5 --- /dev/null +++ b/examples/demo_pods/src/components/modals/MultiPairInputModal.tsx @@ -0,0 +1,119 @@ +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; + firstPlaceholder: string; + secondPlaceholder: string; + onClose: () => void; + onSubmit: (pairs: Record) => void; +} + +const MultiPairInputModal: FC = ({ + open, + title, + firstPlaceholder, + secondPlaceholder, + 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={firstPlaceholder} + /> + + setRows((prev) => + prev.map((entry, entryIndex) => + entryIndex === index ? { ...entry, value: event.target.value } : entry, + ), + ) + } + placeholder={secondPlaceholder} + /> + {rows.length > 1 ? ( + + ) : null} +
+ {index < rows.length - 1 ?
: null} +
+ ))} + +
+ + +
+ + + ); +}; + +export default MultiPairInputModal; diff --git a/examples/demo_pods/src/components/modals/MultiSelectRemoveModal.tsx b/examples/demo_pods/src/components/modals/MultiSelectRemoveModal.tsx new file mode 100644 index 0000000..2043051 --- /dev/null +++ b/examples/demo_pods/src/components/modals/MultiSelectRemoveModal.tsx @@ -0,0 +1,68 @@ +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_pods/src/components/modals/OutcomeModal.tsx b/examples/demo_pods/src/components/modals/OutcomeModal.tsx new file mode 100644 index 0000000..448f875 --- /dev/null +++ b/examples/demo_pods/src/components/modals/OutcomeModal.tsx @@ -0,0 +1,87 @@ +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" + /> + {mode === 'value' ? ( + setValue(event.target.value)} + placeholder="Outcome Value" + /> + ) : null} +
+ + +
+
+
+ ); +}; + +export default OutcomeModal; diff --git a/examples/demo_pods/src/components/modals/PairInputModal.tsx b/examples/demo_pods/src/components/modals/PairInputModal.tsx new file mode 100644 index 0000000..f1c96c4 --- /dev/null +++ b/examples/demo_pods/src/components/modals/PairInputModal.tsx @@ -0,0 +1,74 @@ +import { useEffect, useState } from 'react'; +import type { FC } from 'react'; + +import ModalShell from './ModalShell'; + +interface PairInputModalProps { + open: boolean; + title: string; + firstPlaceholder: string; + secondPlaceholder: string; + confirmLabel: string; + onClose: () => void; + onSubmit: (first: string, second: string) => void; +} + +const PairInputModal: FC = ({ + open, + title, + firstPlaceholder, + secondPlaceholder, + confirmLabel, + onClose, + onSubmit, +}) => { + const [first, setFirst] = useState(''); + const [second, setSecond] = useState(''); + + useEffect(() => { + if (open) { + setFirst(''); + setSecond(''); + } + }, [open]); + + return ( + +
{ + event.preventDefault(); + const firstValue = first.trim(); + const secondValue = second.trim(); + if (!firstValue || !secondValue) return; + onSubmit(firstValue, secondValue); + }} + > +

{title}

+
+ setFirst(event.target.value)} + placeholder={firstPlaceholder} + /> + setSecond(event.target.value)} + placeholder={secondPlaceholder} + /> +
+
+ + +
+
+
+ ); +}; + +export default PairInputModal; diff --git a/examples/demo_pods/src/components/modals/SingleInputModal.tsx b/examples/demo_pods/src/components/modals/SingleInputModal.tsx new file mode 100644 index 0000000..16dd406 --- /dev/null +++ b/examples/demo_pods/src/components/modals/SingleInputModal.tsx @@ -0,0 +1,62 @@ +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; +} + +const SingleInputModal: FC = ({ + open, + title, + placeholder, + confirmLabel, + onClose, + onSubmit, +}) => { + 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} + /> +
+ + +
+
+
+ ); +}; + +export default SingleInputModal; diff --git a/examples/demo_pods/src/components/modals/TooltipModal.tsx b/examples/demo_pods/src/components/modals/TooltipModal.tsx new file mode 100644 index 0000000..89c2999 --- /dev/null +++ b/examples/demo_pods/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_pods/src/components/modals/TrackEventModal.tsx b/examples/demo_pods/src/components/modals/TrackEventModal.tsx new file mode 100644 index 0000000..452dcd2 --- /dev/null +++ b/examples/demo_pods/src/components/modals/TrackEventModal.tsx @@ -0,0 +1,82 @@ +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" + /> +