diff --git a/android/README.md b/android/README.md new file mode 100644 index 0000000..de7537a --- /dev/null +++ b/android/README.md @@ -0,0 +1,22 @@ +# OneSignal Capacitor Plugin – Android + +Thin Capacitor wrapper around the OneSignal Android SDK. Designed to be consumed as a Capacitor sub-project under both Capacitor 7 and Capacitor 8. + +## Kotlin / AGP toolchain + +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. + +Defaults live in [`gradle/libs.versions.toml`](gradle/libs.versions.toml): + +- `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). +- `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. + +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. + +## SDK levels + +`compileSdk`, `minSdk`, and `targetSdk` default to the Capacitor 8 floors (36 / 24 / 36). Host apps override any of them by setting the matching `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. + +## Library versions + +`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`). diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 441d268..0c8f07b 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -24,11 +24,23 @@ buildscript { return result ?: error("Version '$key' not found in ${catalogFile.name}") } - val kotlinVersion: String = if (project.hasProperty("kotlin_version")) { - rootProject.extra["kotlin_version"] as String - } else { - fromCatalog("kotlin") - } + // Both AGP and Kotlin Gradle Plugin are classpathed here so the plugin + // builds inside Capacitor 7 hosts, whose root build.gradle does not + // provide either for sub-projects. Capacitor 8 hosts that already pin + // their own kotlin_version can override via rootProject.ext.kotlin_version. + // + // The catalog default matches the Capacitor 8 upgrade guide's + // recommended kotlin_version (2.2.20). That matters because the host + // classpath can resolve kotlin-stdlib to 2.x; the 1.9 compiler can't + // read 2.x metadata, which is exactly what broke 1.0.2 on Capacitor 8 + // (issue #18). A 2.2.x compiler reads both 1.x and 2.x stdlib bytecode, + // so the plugin works under Cap 7 and Cap 8. + // findProperty matches hasProperty's broad source set (extras, gradle.properties, + // -P flags, ORG_GRADLE_PROJECT_* env vars). Reading rootProject.extra directly + // would only see ext { ... } values and crash on the others with + // UnknownPropertyException, so prefer findProperty + toString(). + val kotlinVersion: String = + project.findProperty("kotlin_version")?.toString() ?: fromCatalog("kotlin") val androidGradlePluginVersion: String = fromCatalog("androidGradlePlugin") repositories { @@ -63,19 +75,14 @@ fun catalogVersion(key: String): String { return result ?: error("Version '$key' not found in ${toml.name}") } +// See the kotlin_version note in buildscript {}: findProperty honors every property +// source hasProperty does (extras, gradle.properties, -P, env), and toString() +// avoids the String/Int cast hazard since gradle.properties values are always String. fun propertyOrCatalog(propertyName: String, catalogKey: String): String = - if (project.hasProperty(propertyName)) { - rootProject.extra[propertyName] as String - } else { - catalogVersion(catalogKey) - } + project.findProperty(propertyName)?.toString() ?: catalogVersion(catalogKey) fun intPropertyOrCatalog(propertyName: String, catalogKey: String): Int = - if (project.hasProperty(propertyName)) { - rootProject.extra[propertyName] as Int - } else { - catalogVersion(catalogKey).toInt() - } + project.findProperty(propertyName)?.toString()?.toInt() ?: catalogVersion(catalogKey).toInt() val junitVersion: String = propertyOrCatalog("junitVersion", "junit") val androidxAppCompatVersion: String = propertyOrCatalog("androidxAppCompatVersion", "androidxAppCompat") @@ -108,7 +115,7 @@ configure { } tasks.withType().configureEach { - kotlinOptions.jvmTarget = "17" + compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) } repositories { diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index b376ca9..85fa1be 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -1,21 +1,32 @@ # Version catalog for the OneSignal Capacitor Android plugin. -# Defaults below can be overridden by the consuming app via gradle -# properties or rootProject.extra (see android/build.gradle.kts). # -# compileSdk / minSdk / targetSdk / kotlin / appcompat / junit follow -# Capacitor 7's required versions, not the OneSignal Android SDK's. +# Host apps can override most defaults by setting the matching +# rootProject.ext. values; see android/build.gradle.kts for the +# property-or-catalog lookup logic. +# +# kotlin: matches Capacitor 8's recommended kotlin_version (2.2.20, per +# Capacitor 8 upgrade docs). A 2.2.x compiler reads kotlin-stdlib bytecode +# from 1.x and 2.x without metadata version errors, which is what makes a +# single artifact compile under both Capacitor 7 hosts (Kotlin 1.9.x +# stdlib) and Capacitor 8 hosts (Kotlin 2.2.x stdlib). +# androidGradlePlugin: kept at 8.7.3. Cap 8 recommends 8.13.0, but bumping +# here would force Gradle 8.13+ in standalone plugin builds, which a +# freshly scaffolded Cap 7 project (Gradle 8.11.1) cannot supply. In host +# builds the host's AGP wins regardless. +# SDK levels / library versions: bumped to Capacitor 8's recommended floors +# for documentation parity. Host apps still override via rootProject.ext. [versions] androidGradlePlugin = "8.7.3" -androidxAppCompat = "1.7.0" -androidxEspresso = "3.6.1" -androidxTestJunit = "1.2.1" -compileSdk = "35" +androidxAppCompat = "1.7.1" +androidxEspresso = "3.7.0" +androidxTestJunit = "1.3.0" +compileSdk = "36" junit = "4.13.2" -kotlin = "1.9.25" -minSdk = "23" +kotlin = "2.2.20" +minSdk = "24" onesignal = "5.9.1" -targetSdk = "35" +targetSdk = "36" [libraries] androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidxAppCompat" } diff --git a/examples/demo_cap7/.gitignore b/examples/demo_cap7/.gitignore new file mode 100644 index 0000000..f774d26 --- /dev/null +++ b/examples/demo_cap7/.gitignore @@ -0,0 +1,3 @@ +# Angular CLI cache + intermediate TS output +.angular/ +out-tsc/ diff --git a/examples/demo_cap7/README.md b/examples/demo_cap7/README.md new file mode 100644 index 0000000..defb819 --- /dev/null +++ b/examples/demo_cap7/README.md @@ -0,0 +1,45 @@ +# demo-cap7 + +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). + +## Stack + +- Capacitor 7 (`@capacitor/core` `^7.4.3`) +- Angular 18 standalone components, bootstrapped with `bootstrapApplication` +- Angular CLI (`ng build` / `ng serve`) – no Ionic, no extra build tooling +- Single root component with four buttons and a signal-backed log + +## What the demo does + +1. Initialize OneSignal +2. Request notification permission +3. Show the OneSignal user / push subscription id (paste it into the OneSignal dashboard to send a test push) +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. + +## First-time setup + +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. + +```bash +# from the repo root: build + pack the plugin tarball +vp run build +vp pm pack && mv onesignal-capacitor-plugin-*.tgz onesignal-capacitor-plugin.tgz + +# in this folder: install deps and the local plugin tarball +cd examples/demo_cap7 +bun install +``` + +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. + +`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. + +## Running + +```bash +bun run build # ng build → dist/browser +bunx cap sync # copy web + plugin into native projects +bunx cap run android # or: bunx cap run ios +``` + +The Angular CLI builder emits to `dist/browser/`; `capacitor.config.ts` points `webDir` there. diff --git a/examples/demo_cap7/android/.gitignore b/examples/demo_cap7/android/.gitignore new file mode 100644 index 0000000..48354a3 --- /dev/null +++ b/examples/demo_cap7/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_cap7/android/app/.gitignore b/examples/demo_cap7/android/app/.gitignore new file mode 100644 index 0000000..043df80 --- /dev/null +++ b/examples/demo_cap7/android/app/.gitignore @@ -0,0 +1,2 @@ +/build/* +!/build/.npmkeep diff --git a/examples/demo_cap7/android/app/build.gradle b/examples/demo_cap7/android/app/build.gradle new file mode 100644 index 0000000..8c0a7f2 --- /dev/null +++ b/examples/demo_cap7/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_cap7/android/app/proguard-rules.pro b/examples/demo_cap7/android/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/examples/demo_cap7/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_cap7/android/app/src/main/AndroidManifest.xml b/examples/demo_cap7/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..340e7df --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo_cap7/android/app/src/main/java/com/onesignal/example/MainActivity.java b/examples/demo_cap7/android/app/src/main/java/com/onesignal/example/MainActivity.java new file mode 100644 index 0000000..933674d --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/java/com/onesignal/example/MainActivity.java @@ -0,0 +1,5 @@ +package com.onesignal.example; + +import com.getcapacitor.BridgeActivity; + +public class MainActivity extends BridgeActivity {} diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-land-hdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-land-hdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-land-mdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-land-mdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-land-xhdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-land-xhdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-land-xxhdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-land-xxhdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-land-xxxhdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-land-xxxhdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-port-hdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-port-hdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-port-mdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-port-mdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-port-xhdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-port-xhdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-port-xxhdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-port-xxhdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-port-xxxhdpi/splash.png b/examples/demo_cap7/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_cap7/android/app/src/main/res/drawable-port-xxxhdpi/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/examples/demo_cap7/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..c7bd21d --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/examples/demo_cap7/android/app/src/main/res/drawable/ic_launcher_background.xml b/examples/demo_cap7/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..d5fccc5 --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo_cap7/android/app/src/main/res/drawable/splash.png b/examples/demo_cap7/android/app/src/main/res/drawable/splash.png new file mode 100644 index 0000000..f7a6492 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/drawable/splash.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/layout/activity_main.xml b/examples/demo_cap7/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b5ad138 --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/demo_cap7/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/demo_cap7/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..c023e50 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..2127973 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..b441f37 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..72905b8 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..8ed0605 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..9502e47 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..4d1e077 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..df0f158 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..853db04 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..6cdf97c Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..2960cbb Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..8e3093a Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..46de6e2 Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..d2ea9ab Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..a40d73e Binary files /dev/null and b/examples/demo_cap7/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/examples/demo_cap7/android/app/src/main/res/values/ic_launcher_background.xml b/examples/demo_cap7/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..c5d5899 --- /dev/null +++ b/examples/demo_cap7/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_cap7/android/app/src/main/res/values/strings.xml b/examples/demo_cap7/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..174446f --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ + + + OneSignal Cap7 Demo + OneSignal Cap7 Demo + com.onesignal.example + com.onesignal.example + diff --git a/examples/demo_cap7/android/app/src/main/res/values/styles.xml b/examples/demo_cap7/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..be874e5 --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/res/values/styles.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/examples/demo_cap7/android/app/src/main/res/xml/file_paths.xml b/examples/demo_cap7/android/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..bd0c4d8 --- /dev/null +++ b/examples/demo_cap7/android/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/demo_cap7/android/build.gradle b/examples/demo_cap7/android/build.gradle new file mode 100644 index 0000000..f1b3b0e --- /dev/null +++ b/examples/demo_cap7/android/build.gradle @@ -0,0 +1,29 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.7.2' + classpath 'com.google.gms:google-services:4.4.2' + + // 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_cap7/android/capacitor.settings.gradle b/examples/demo_cap7/android/capacitor.settings.gradle new file mode 100644 index 0000000..fd6c230 --- /dev/null +++ b/examples/demo_cap7/android/capacitor.settings.gradle @@ -0,0 +1,6 @@ +// 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 ':onesignal-capacitor-plugin' +project(':onesignal-capacitor-plugin').projectDir = new File('../node_modules/@onesignal/capacitor-plugin/android') diff --git a/examples/demo_cap7/android/gradle.properties b/examples/demo_cap7/android/gradle.properties new file mode 100644 index 0000000..2e87c52 --- /dev/null +++ b/examples/demo_cap7/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_cap7/android/gradle/wrapper/gradle-wrapper.jar b/examples/demo_cap7/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..a4b76b9 Binary files /dev/null and b/examples/demo_cap7/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/demo_cap7/android/gradle/wrapper/gradle-wrapper.properties b/examples/demo_cap7/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..c1d5e01 --- /dev/null +++ b/examples/demo_cap7/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.11.1-all.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/examples/demo_cap7/android/gradlew b/examples/demo_cap7/android/gradlew new file mode 100755 index 0000000..f5feea6 --- /dev/null +++ b/examples/demo_cap7/android/gradlew @@ -0,0 +1,252 @@ +#!/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 +' "$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=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# 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, 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" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# 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_cap7/android/gradlew.bat b/examples/demo_cap7/android/gradlew.bat new file mode 100644 index 0000000..9b42019 --- /dev/null +++ b/examples/demo_cap7/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=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +: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_cap7/android/settings.gradle b/examples/demo_cap7/android/settings.gradle new file mode 100644 index 0000000..3b4431d --- /dev/null +++ b/examples/demo_cap7/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_cap7/android/variables.gradle b/examples/demo_cap7/android/variables.gradle new file mode 100644 index 0000000..1bb4164 --- /dev/null +++ b/examples/demo_cap7/android/variables.gradle @@ -0,0 +1,16 @@ +ext { + minSdkVersion = 24 + compileSdkVersion = 35 + targetSdkVersion = 35 + androidxActivityVersion = '1.9.2' + androidxAppCompatVersion = '1.7.0' + androidxCoordinatorLayoutVersion = '1.2.0' + androidxCoreVersion = '1.15.0' + androidxFragmentVersion = '1.8.4' + coreSplashScreenVersion = '1.0.1' + androidxWebkitVersion = '1.12.1' + junitVersion = '4.13.2' + androidxJunitVersion = '1.2.1' + androidxEspressoCoreVersion = '3.6.1' + cordovaAndroidVersion = '10.1.1' +} \ No newline at end of file diff --git a/examples/demo_cap7/angular.json b/examples/demo_cap7/angular.json new file mode 100644 index 0000000..b742ebf --- /dev/null +++ b/examples/demo_cap7/angular.json @@ -0,0 +1,55 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "demo-cap7": { + "projectType": "application", + "schematics": {}, + "root": "", + "sourceRoot": "src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:application", + "options": { + "outputPath": "dist", + "index": "src/index.html", + "browser": "src/main.ts", + "polyfills": ["zone.js"], + "tsConfig": "tsconfig.app.json", + "assets": [], + "styles": ["src/styles.css"], + "scripts": [] + }, + "configurations": { + "production": { + "outputHashing": "all" + }, + "development": { + "optimization": false, + "extractLicenses": false, + "sourceMap": true + } + }, + "defaultConfiguration": "production" + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "configurations": { + "production": { + "buildTarget": "demo-cap7:build:production" + }, + "development": { + "buildTarget": "demo-cap7:build:development" + } + }, + "defaultConfiguration": "development" + } + } + } + }, + "cli": { + "analytics": false + } +} diff --git a/examples/demo_cap7/capacitor.config.ts b/examples/demo_cap7/capacitor.config.ts new file mode 100644 index 0000000..4dab359 --- /dev/null +++ b/examples/demo_cap7/capacitor.config.ts @@ -0,0 +1,18 @@ +import type { CapacitorConfig } from '@capacitor/cli'; + +const config: CapacitorConfig = { + appId: 'com.onesignal.example', + appName: 'OneSignal Cap7 Demo', + webDir: 'dist/browser', + loggingBehavior: 'debug', + ios: { + // Disable Capacitor's UNUserNotificationCenterDelegate swizzling so the + // OneSignal iOS SDK can install its own foreground delegate. Without this, + // pushes arriving while the app is foregrounded are silently suppressed + // (token registration still succeeds, which is why the device shows up + // on the OneSignal dashboard regardless). + handleApplicationNotifications: false, + }, +}; + +export default config; diff --git a/examples/demo_cap7/ios/.gitignore b/examples/demo_cap7/ios/.gitignore new file mode 100644 index 0000000..f470299 --- /dev/null +++ b/examples/demo_cap7/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_cap7/ios/App/App.xcodeproj/project.pbxproj b/examples/demo_cap7/ios/App/App.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e1610fa --- /dev/null +++ b/examples/demo_cap7/ios/App/App.xcodeproj/project.pbxproj @@ -0,0 +1,416 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + 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 */; }; + A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = ""; }; + 50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = ""; }; + 504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 504EC3071FED79650016851F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 504EC30C1FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = ""; }; + 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 = ""; }; + E86F636C2FB642C500EF4766 /* AppRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AppRelease.entitlements; sourceTree = ""; }; + E86F636D2FB642E600EF4766 /* AppDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AppDebug.entitlements; 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 PBXFrameworksBuildPhase section */ + 504EC3011FED79650016851F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */ = { + isa = PBXGroup; + children = ( + AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 504EC2FB1FED79650016851F = { + isa = PBXGroup; + children = ( + 504EC3061FED79650016851F /* App */, + 504EC3051FED79650016851F /* Products */, + 7F8756D8B27F46E3366F6CEA /* Pods */, + 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */, + ); + sourceTree = ""; + }; + 504EC3051FED79650016851F /* Products */ = { + isa = PBXGroup; + children = ( + 504EC3041FED79650016851F /* App.app */, + ); + name = Products; + sourceTree = ""; + }; + 504EC3061FED79650016851F /* App */ = { + isa = PBXGroup; + children = ( + E86F636D2FB642E600EF4766 /* AppDebug.entitlements */, + E86F636C2FB642C500EF4766 /* AppRelease.entitlements */, + 50379B222058CBB4000EE86E /* capacitor.config.json */, + 504EC3071FED79650016851F /* AppDelegate.swift */, + 504EC30B1FED79650016851F /* Main.storyboard */, + 504EC30E1FED79650016851F /* Assets.xcassets */, + 504EC3101FED79650016851F /* LaunchScreen.storyboard */, + 504EC3131FED79650016851F /* Info.plist */, + 2FAD9762203C412B000D30F8 /* config.xml */, + 50B271D01FEDC1A000F3C39B /* public */, + ); + path = App; + sourceTree = ""; + }; + 7F8756D8B27F46E3366F6CEA /* Pods */ = { + isa = PBXGroup; + children = ( + FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */, + AF51FD2D460BCFE21FA515B2 /* Pods-App.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 */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = App; + productName = App; + productReference = 504EC3041FED79650016851F /* App.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 504EC2FC1FED79650016851F /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 0920; + TargetAttributes = { + 504EC3031FED79650016851F = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 504EC2FB1FED79650016851F; + packageReferences = ( + ); + productRefGroup = 504EC3051FED79650016851F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 504EC3031FED79650016851F /* App */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 504EC3021FED79650016851F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */, + 50B271D11FEDC1A000F3C39B /* public in Resources */, + 504EC30F1FED79650016851F /* Assets.xcassets in Resources */, + 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */, + 504EC30D1FED79650016851F /* Main.storyboard in Resources */, + 2FAD9763203C412B000D30F8 /* config.xml in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 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; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 504EC3001FED79650016851F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3081FED79650016851F /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase 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 = 14.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 = 14.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + 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/AppDebug.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + INFOPLIST_FILE = App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.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/AppRelease.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + INFOPLIST_FILE = App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.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; + }; +/* 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; + }; +/* End XCConfigurationList section */ + }; + rootObject = 504EC2FC1FED79650016851F /* Project object */; +} diff --git a/examples/demo_cap7/ios/App/App.xcworkspace/contents.xcworkspacedata b/examples/demo_cap7/ios/App/App.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..b301e82 --- /dev/null +++ b/examples/demo_cap7/ios/App/App.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/examples/demo_cap7/ios/App/App/AppDebug.entitlements b/examples/demo_cap7/ios/App/App/AppDebug.entitlements new file mode 100644 index 0000000..903def2 --- /dev/null +++ b/examples/demo_cap7/ios/App/App/AppDebug.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + diff --git a/examples/demo_cap7/ios/App/App/AppDelegate.swift b/examples/demo_cap7/ios/App/App/AppDelegate.swift new file mode 100644 index 0000000..c3cd83b --- /dev/null +++ b/examples/demo_cap7/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_cap7/ios/App/App/AppRelease.entitlements b/examples/demo_cap7/ios/App/App/AppRelease.entitlements new file mode 100644 index 0000000..903def2 --- /dev/null +++ b/examples/demo_cap7/ios/App/App/AppRelease.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + diff --git a/examples/demo_cap7/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png b/examples/demo_cap7/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png new file mode 100644 index 0000000..adf6ba0 Binary files /dev/null and b/examples/demo_cap7/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png differ diff --git a/examples/demo_cap7/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/demo_cap7/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..00b5bd3 --- /dev/null +++ b/examples/demo_cap7/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images": [ + { + "filename": "AppIcon-512@2x.png", + "idiom": "universal", + "platform": "ios", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/examples/demo_cap7/ios/App/App/Assets.xcassets/Contents.json b/examples/demo_cap7/ios/App/App/Assets.xcassets/Contents.json new file mode 100644 index 0000000..97a8662 --- /dev/null +++ b/examples/demo_cap7/ios/App/App/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "version": 1, + "author": "xcode" + } +} diff --git a/examples/demo_cap7/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json b/examples/demo_cap7/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json new file mode 100644 index 0000000..b781492 --- /dev/null +++ b/examples/demo_cap7/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_cap7/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png b/examples/demo_cap7/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_cap7/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png differ diff --git a/examples/demo_cap7/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png b/examples/demo_cap7/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_cap7/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png differ diff --git a/examples/demo_cap7/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png b/examples/demo_cap7/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_cap7/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png differ diff --git a/examples/demo_cap7/ios/App/App/Base.lproj/LaunchScreen.storyboard b/examples/demo_cap7/ios/App/App/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..e7ae5d7 --- /dev/null +++ b/examples/demo_cap7/ios/App/App/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo_cap7/ios/App/App/Base.lproj/Main.storyboard b/examples/demo_cap7/ios/App/App/Base.lproj/Main.storyboard new file mode 100644 index 0000000..b44df7b --- /dev/null +++ b/examples/demo_cap7/ios/App/App/Base.lproj/Main.storyboard @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/examples/demo_cap7/ios/App/App/Info.plist b/examples/demo_cap7/ios/App/App/Info.plist new file mode 100644 index 0000000..761eb8b --- /dev/null +++ b/examples/demo_cap7/ios/App/App/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + OneSignal Cap7 Demo + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/examples/demo_cap7/ios/App/Podfile b/examples/demo_cap7/ios/App/Podfile new file mode 100644 index 0000000..ca068b2 --- /dev/null +++ b/examples/demo_cap7/ios/App/Podfile @@ -0,0 +1,24 @@ +require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers' + +platform :ios, '14.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 '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 diff --git a/examples/demo_cap7/package.json b/examples/demo_cap7/package.json new file mode 100644 index 0000000..b1bd4ac --- /dev/null +++ b/examples/demo_cap7/package.json @@ -0,0 +1,33 @@ +{ + "name": "demo-cap7", + "version": "1.0.0", + "private": true, + "scripts": { + "android": "bunx cap run android", + "build": "ng build", + "dev": "ng serve --host 0.0.0.0 --port 5173", + "ios": "bunx cap run ios", + "sync": "bunx cap sync" + }, + "dependencies": { + "@angular/common": "^18.2.0", + "@angular/compiler": "^18.2.0", + "@angular/core": "^18.2.0", + "@angular/platform-browser": "^18.2.0", + "@capacitor/android": "^7.4.3", + "@capacitor/core": "^7.4.3", + "@capacitor/ios": "^7.4.3", + "@onesignal/capacitor-plugin": "file:../../onesignal-capacitor-plugin.tgz", + "rxjs": "^7.8.1", + "tslib": "^2.7.0", + "zone.js": "~0.14.10" + }, + "devDependencies": { + "@angular-devkit/build-angular": "^18.2.0", + "@angular/cli": "^18.2.0", + "@angular/compiler-cli": "^18.2.0", + "@capacitor/cli": "^7.4.3", + "typescript": "~5.5.4" + }, + "packageManager": "bun@1.3.14" +} diff --git a/examples/demo_cap7/src/app/app.component.ts b/examples/demo_cap7/src/app/app.component.ts new file mode 100644 index 0000000..e6ce849 --- /dev/null +++ b/examples/demo_cap7/src/app/app.component.ts @@ -0,0 +1,125 @@ +import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; +import { CapacitorHttp } from '@capacitor/core'; +import OneSignal, { LogLevel } from '@onesignal/capacitor-plugin'; + +const ONESIGNAL_APP_ID = '77e32082-ea27-42e3-a898-c72e141824ef'; + +@Component({ + selector: 'app-root', + standalone: true, + changeDetection: ChangeDetectionStrategy.OnPush, + template: ` +

OneSignal Capacitor 7 Demo

+

Hello-world for verifying the OneSignal plugin on Capacitor 7.

+ + + + + + +
{{ logText() }}
+ `, +}) +export class AppComponent { + protected readonly initialized = signal(false); + protected readonly sending = signal(false); + protected readonly logText = signal('Ready. Tap "Initialize OneSignal" to start.'); + + protected initialize(): void { + if (this.initialized()) { + this.log('Already initialized.'); + return; + } + OneSignal.Debug.setLogLevel(LogLevel.Verbose); + void OneSignal.initialize(ONESIGNAL_APP_ID); + + OneSignal.Notifications.addEventListener('foregroundWillDisplay', (event) => { + const n = event.getNotification(); + this.log(`foregroundWillDisplay: ${n.title ?? '(no title)'}`); + }); + + this.initialized.set(true); + this.log(`OneSignal initialized with app id ${ONESIGNAL_APP_ID}`); + } + + protected async requestPermission(): Promise { + try { + const accepted = await OneSignal.Notifications.requestPermission(true); + this.log(`Permission accepted: ${String(accepted)}`); + } catch (err) { + this.log(`requestPermission error: ${String(err)}`); + } + } + + protected async showSubscriptionInfo(): Promise { + try { + const [onesignalId, subscriptionId, optedIn, hasPerm] = await Promise.all([ + OneSignal.User.getOnesignalId(), + OneSignal.User.pushSubscription.getIdAsync(), + OneSignal.User.pushSubscription.getOptedInAsync(), + OneSignal.Notifications.hasPermission(), + ]); + this.log( + [ + `OneSignal user id: ${onesignalId ?? '(none)'}`, + `Push subscription id: ${subscriptionId ?? '(none)'}`, + `Opted in: ${String(optedIn)}`, + `Has permission: ${String(hasPerm)}`, + '', + 'Send a test push to the subscription id above', + 'from the OneSignal dashboard to see it appear.', + ].join('\n'), + ); + } catch (err) { + this.log(`showSubscriptionInfo error: ${String(err)}`); + } + } + + protected async sendTestNotification(): Promise { + this.sending.set(true); + try { + const subscriptionId = await OneSignal.User.pushSubscription.getIdAsync(); + if (!subscriptionId) { + this.log('No push subscription id yet. Grant permission first.'); + return; + } + + const response = await CapacitorHttp.post({ + url: 'https://onesignal.com/api/v1/notifications', + headers: { + Accept: 'application/vnd.onesignal.v1+json', + 'Content-Type': 'application/json', + }, + data: { + app_id: ONESIGNAL_APP_ID, + include_subscription_ids: [subscriptionId], + headings: { en: 'Simple Notification' }, + contents: { en: 'This is a simple push notification' }, + }, + }); + + if (response.status < 200 || response.status >= 300) { + this.log(`Send failed (${response.status}): ${JSON.stringify(response.data)}`); + return; + } + + this.log(`Sent. response: ${JSON.stringify(response.data)}`); + } catch (err) { + this.log(`sendTestNotification error: ${String(err)}`); + } finally { + this.sending.set(false); + } + } + + private log(message: string): void { + const stamp = new Date().toISOString().slice(11, 19); + this.logText.update((prev) => `[${stamp}] ${message}\n${prev}`); + console.log(`[demo-cap7] ${message}`); + } +} diff --git a/examples/demo_cap7/src/index.html b/examples/demo_cap7/src/index.html new file mode 100644 index 0000000..625aff1 --- /dev/null +++ b/examples/demo_cap7/src/index.html @@ -0,0 +1,15 @@ + + + + + + OneSignal Capacitor 7 Demo + + + + + + diff --git a/examples/demo_cap7/src/main.ts b/examples/demo_cap7/src/main.ts new file mode 100644 index 0000000..97939e0 --- /dev/null +++ b/examples/demo_cap7/src/main.ts @@ -0,0 +1,7 @@ +import { bootstrapApplication } from '@angular/platform-browser'; + +import { AppComponent } from './app/app.component'; + +bootstrapApplication(AppComponent).catch((err: unknown) => { + console.error(err); +}); diff --git a/examples/demo_cap7/src/styles.css b/examples/demo_cap7/src/styles.css new file mode 100644 index 0000000..e1bf4e3 --- /dev/null +++ b/examples/demo_cap7/src/styles.css @@ -0,0 +1,50 @@ +:root { + color-scheme: light dark; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; +} + +body { + margin: 0; + padding: 24px 20px env(safe-area-inset-bottom) 20px; + padding-top: calc(env(safe-area-inset-top) + 24px); +} + +h1 { + font-size: 22px; + margin: 0 0 4px; +} + +p.subtitle { + margin: 0 0 24px; + opacity: 0.7; + font-size: 14px; +} + +button { + display: block; + width: 100%; + padding: 14px 16px; + margin: 0 0 12px; + font-size: 16px; + border-radius: 10px; + border: 1px solid #888; + background: #007aff; + color: #fff; + cursor: pointer; +} + +button:disabled { + opacity: 0.5; +} + +pre { + margin-top: 24px; + padding: 12px; + background: rgba(127, 127, 127, 0.15); + border-radius: 8px; + font-size: 12px; + white-space: pre-wrap; + word-break: break-all; + max-height: 280px; + overflow: auto; +} diff --git a/examples/demo_cap7/tsconfig.app.json b/examples/demo_cap7/tsconfig.app.json new file mode 100644 index 0000000..5b9d3c5 --- /dev/null +++ b/examples/demo_cap7/tsconfig.app.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": ["src/main.ts"], + "include": ["src/**/*.d.ts"] +} diff --git a/examples/demo_cap7/tsconfig.json b/examples/demo_cap7/tsconfig.json new file mode 100644 index 0000000..f5ac023 --- /dev/null +++ b/examples/demo_cap7/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "outDir": "./dist/out-tsc", + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "skipLibCheck": true, + "isolatedModules": true, + "experimentalDecorators": true, + "importHelpers": true, + "target": "ES2022", + "module": "ES2022", + "moduleResolution": "bundler", + "useDefineForClassFields": false, + "lib": ["ES2022", "dom"] + }, + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +}