You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thin Capacitor wrapper around the OneSignal Android SDK. Designed to be consumed as a Capacitor sub-project under both Capacitor 7 and Capacitor 8.
4
+
5
+
## Kotlin / AGP toolchain
6
+
7
+
The plugin module declares its own `buildscript` classpath for the Android Gradle Plugin and the Kotlin Gradle Plugin. This is required because Capacitor 7's host `build.gradle` does not classpath the Kotlin Gradle Plugin for sub-projects; without our own classpath the `kotlin-android` plugin would fail to resolve.
8
+
9
+
Defaults live in [`gradle/libs.versions.toml`](gradle/libs.versions.toml):
10
+
11
+
-`kotlin = "2.2.20"` – the compiler version used to build this module. Matches the Capacitor 8 upgrade guide's recommended `kotlin_version`, and a 2.2.x compiler reads `kotlin-stdlib` bytecode from both 1.x and 2.x, which is what makes a single artifact work on Capacitor 7 hosts (Kotlin 1.9.x stdlib) and Capacitor 8 hosts (Kotlin 2.2.x stdlib).
12
+
-`androidGradlePlugin = "8.7.3"` – intentionally stays below Capacitor 8's recommended 8.13.0 so plugin-only Gradle invocations still work from a freshly scaffolded Capacitor 7 project (Gradle 8.11.1). In host builds the host's AGP wins regardless.
13
+
14
+
Host apps that need to pin a different Kotlin compiler can do so via any standard Gradle property source — `rootProject.ext.kotlin_version` in their root `build.gradle`, `kotlin_version=…` in `gradle.properties`, or `-Pkotlin_version=…` on the command line. The plugin's buildscript block reads the value through `project.findProperty("kotlin_version")` and falls back to the catalog default.
15
+
16
+
## SDK levels
17
+
18
+
`compileSdk`, `minSdk`, and `targetSdk` default to the Capacitor 8 floors (36 / 24 / 36). Host apps override any of them by setting the matching `<name>Version` property through any Gradle property source (`rootProject.ext`, `gradle.properties`, or `-P`) — Capacitor 7 host apps that ship with `variables.gradle` defaults of 35 / 23 / 35 will continue to take precedence over the catalog defaults.
19
+
20
+
## Library versions
21
+
22
+
`androidx.appcompat`, `junit`, espresso, and the OneSignal native SDK versions also live in [`gradle/libs.versions.toml`](gradle/libs.versions.toml). `androidxAppCompatVersion` and `junitVersion` can be overridden per-project through any Gradle property source (`rootProject.ext`, `gradle.properties`, or `-P`).
Minimal Capacitor 7 + Angular sample used to verify the OneSignal Capacitor plugin against the older Kotlin / AGP toolchain that Capacitor 7 ships with. Pairs with `examples/demo` (Capacitor 8, Ionic React).
4
+
5
+
## Stack
6
+
7
+
- Capacitor 7 (`@capacitor/core``^7.4.3`)
8
+
- Angular 18 standalone components, bootstrapped with `bootstrapApplication`
9
+
- Angular CLI (`ng build` / `ng serve`) – no Ionic, no extra build tooling
10
+
- Single root component with four buttons and a signal-backed log
11
+
12
+
## What the demo does
13
+
14
+
1. Initialize OneSignal
15
+
2. Request notification permission
16
+
3. Show the OneSignal user / push subscription id (paste it into the OneSignal dashboard to send a test push)
17
+
4. Send Test Notification – POSTs `{ headings: 'Simple Notification', contents: 'This is a simple push notification' }` to the OneSignal REST API (`v1/notifications`) targeting the current push subscription id. Mirrors the Simple notification button in `examples/demo`; no REST API key needed since the call targets the device's own subscription id.
18
+
19
+
## First-time setup
20
+
21
+
The `android/` and `ios/` projects are committed (scaffolded via Capacitor 7's CLI, AGP 8.7.x, no root Kotlin Gradle Plugin classpath), so the only setup is dependencies and the plugin tarball.
22
+
23
+
```bash
24
+
# from the repo root: build + pack the plugin tarball
# in this folder: install deps and the local plugin tarball
29
+
cd examples/demo_cap7
30
+
bun install
31
+
```
32
+
33
+
The OneSignal plugin module compiles against the Kotlin 2.2.20 compiler it ships in its own buildscript classpath, which reads both 1.x and 2.x `kotlin-stdlib` bytecode.
34
+
35
+
`ONESIGNAL_APP_ID` in `src/app/app.component.ts` defaults to the shared OneSignal demo app id (same one used by `examples/demo`). Swap it for your own app id before pointing the demo at a production environment.
36
+
37
+
## Running
38
+
39
+
```bash
40
+
bun run build # ng build → dist/browser
41
+
bunx cap sync # copy web + plugin into native projects
42
+
bunx cap run android # or: bunx cap run ios
43
+
```
44
+
45
+
The Angular CLI builder emits to `dist/browser/`; `capacitor.config.ts` points `webDir` there.
0 commit comments