@onesignal/capacitor-plugin 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle.kts +23 -16
- package/android/gradle/libs.versions.toml +23 -12
- package/android/src/main/kotlin/com/onesignal/capacitor/OneSignalCapacitorPlugin.kt +6 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -3
- package/ios/Sources/OneSignalCapacitorPlugin/OneSignalCapacitorPlugin.swift +6 -1
- package/package.json +3 -4
package/android/build.gradle.kts
CHANGED
|
@@ -24,11 +24,23 @@ buildscript {
|
|
|
24
24
|
return result ?: error("Version '$key' not found in ${catalogFile.name}")
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
// Both AGP and Kotlin Gradle Plugin are classpathed here so the plugin
|
|
28
|
+
// builds inside Capacitor 7 hosts, whose root build.gradle does not
|
|
29
|
+
// provide either for sub-projects. Capacitor 8 hosts that already pin
|
|
30
|
+
// their own kotlin_version can override via rootProject.ext.kotlin_version.
|
|
31
|
+
//
|
|
32
|
+
// The catalog default matches the Capacitor 8 upgrade guide's
|
|
33
|
+
// recommended kotlin_version (2.2.20). That matters because the host
|
|
34
|
+
// classpath can resolve kotlin-stdlib to 2.x; the 1.9 compiler can't
|
|
35
|
+
// read 2.x metadata, which is exactly what broke 1.0.2 on Capacitor 8
|
|
36
|
+
// (issue #18). A 2.2.x compiler reads both 1.x and 2.x stdlib bytecode,
|
|
37
|
+
// so the plugin works under Cap 7 and Cap 8.
|
|
38
|
+
// findProperty matches hasProperty's broad source set (extras, gradle.properties,
|
|
39
|
+
// -P flags, ORG_GRADLE_PROJECT_* env vars). Reading rootProject.extra directly
|
|
40
|
+
// would only see ext { ... } values and crash on the others with
|
|
41
|
+
// UnknownPropertyException, so prefer findProperty + toString().
|
|
42
|
+
val kotlinVersion: String =
|
|
43
|
+
project.findProperty("kotlin_version")?.toString() ?: fromCatalog("kotlin")
|
|
32
44
|
val androidGradlePluginVersion: String = fromCatalog("androidGradlePlugin")
|
|
33
45
|
|
|
34
46
|
repositories {
|
|
@@ -63,19 +75,14 @@ fun catalogVersion(key: String): String {
|
|
|
63
75
|
return result ?: error("Version '$key' not found in ${toml.name}")
|
|
64
76
|
}
|
|
65
77
|
|
|
78
|
+
// See the kotlin_version note in buildscript {}: findProperty honors every property
|
|
79
|
+
// source hasProperty does (extras, gradle.properties, -P, env), and toString()
|
|
80
|
+
// avoids the String/Int cast hazard since gradle.properties values are always String.
|
|
66
81
|
fun propertyOrCatalog(propertyName: String, catalogKey: String): String =
|
|
67
|
-
|
|
68
|
-
rootProject.extra[propertyName] as String
|
|
69
|
-
} else {
|
|
70
|
-
catalogVersion(catalogKey)
|
|
71
|
-
}
|
|
82
|
+
project.findProperty(propertyName)?.toString() ?: catalogVersion(catalogKey)
|
|
72
83
|
|
|
73
84
|
fun intPropertyOrCatalog(propertyName: String, catalogKey: String): Int =
|
|
74
|
-
|
|
75
|
-
rootProject.extra[propertyName] as Int
|
|
76
|
-
} else {
|
|
77
|
-
catalogVersion(catalogKey).toInt()
|
|
78
|
-
}
|
|
85
|
+
project.findProperty(propertyName)?.toString()?.toInt() ?: catalogVersion(catalogKey).toInt()
|
|
79
86
|
|
|
80
87
|
val junitVersion: String = propertyOrCatalog("junitVersion", "junit")
|
|
81
88
|
val androidxAppCompatVersion: String = propertyOrCatalog("androidxAppCompatVersion", "androidxAppCompat")
|
|
@@ -108,7 +115,7 @@ configure<com.android.build.gradle.LibraryExtension> {
|
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
|
111
|
-
|
|
118
|
+
compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
repositories {
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
# Version catalog for the OneSignal Capacitor Android plugin.
|
|
2
|
-
# Defaults below can be overridden by the consuming app via gradle
|
|
3
|
-
# properties or rootProject.extra (see android/build.gradle.kts).
|
|
4
2
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
3
|
+
# Host apps can override most defaults by setting the matching
|
|
4
|
+
# rootProject.ext.<key> values; see android/build.gradle.kts for the
|
|
5
|
+
# property-or-catalog lookup logic.
|
|
6
|
+
#
|
|
7
|
+
# kotlin: matches Capacitor 8's recommended kotlin_version (2.2.20, per
|
|
8
|
+
# Capacitor 8 upgrade docs). A 2.2.x compiler reads kotlin-stdlib bytecode
|
|
9
|
+
# from 1.x and 2.x without metadata version errors, which is what makes a
|
|
10
|
+
# single artifact compile under both Capacitor 7 hosts (Kotlin 1.9.x
|
|
11
|
+
# stdlib) and Capacitor 8 hosts (Kotlin 2.2.x stdlib).
|
|
12
|
+
# androidGradlePlugin: kept at 8.7.3. Cap 8 recommends 8.13.0, but bumping
|
|
13
|
+
# here would force Gradle 8.13+ in standalone plugin builds, which a
|
|
14
|
+
# freshly scaffolded Cap 7 project (Gradle 8.11.1) cannot supply. In host
|
|
15
|
+
# builds the host's AGP wins regardless.
|
|
16
|
+
# SDK levels / library versions: bumped to Capacitor 8's recommended floors
|
|
17
|
+
# for documentation parity. Host apps still override via rootProject.ext.
|
|
7
18
|
|
|
8
19
|
[versions]
|
|
9
20
|
androidGradlePlugin = "8.7.3"
|
|
10
|
-
androidxAppCompat = "1.7.
|
|
11
|
-
androidxEspresso = "3.
|
|
12
|
-
androidxTestJunit = "1.
|
|
13
|
-
compileSdk = "
|
|
21
|
+
androidxAppCompat = "1.7.1"
|
|
22
|
+
androidxEspresso = "3.7.0"
|
|
23
|
+
androidxTestJunit = "1.3.0"
|
|
24
|
+
compileSdk = "36"
|
|
14
25
|
junit = "4.13.2"
|
|
15
|
-
kotlin = "
|
|
16
|
-
minSdk = "
|
|
17
|
-
onesignal = "5.
|
|
18
|
-
targetSdk = "
|
|
26
|
+
kotlin = "2.2.20"
|
|
27
|
+
minSdk = "24"
|
|
28
|
+
onesignal = "5.9.1"
|
|
29
|
+
targetSdk = "36"
|
|
19
30
|
|
|
20
31
|
[libraries]
|
|
21
32
|
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidxAppCompat" }
|
|
@@ -134,7 +134,7 @@ class OneSignalCapacitorPlugin : Plugin(),
|
|
|
134
134
|
initialized = true
|
|
135
135
|
|
|
136
136
|
OneSignalWrapper.sdkType = "capacitor"
|
|
137
|
-
OneSignalWrapper.sdkVersion = "
|
|
137
|
+
OneSignalWrapper.sdkVersion = "010004"
|
|
138
138
|
OneSignal.initWithContext(context, appId)
|
|
139
139
|
|
|
140
140
|
// If the SDK was initialized from a non-Activity context (FCM/work
|
|
@@ -718,6 +718,11 @@ class OneSignalCapacitorPlugin : Plugin(),
|
|
|
718
718
|
// region Observer Callbacks
|
|
719
719
|
|
|
720
720
|
override fun onWillDisplay(event: INotificationWillDisplayEvent) {
|
|
721
|
+
// Match Cordova's default-display behavior: if no JS listener has
|
|
722
|
+
// subscribed via Notifications.addEventListener('foregroundWillDisplay'),
|
|
723
|
+
// leave the event untouched so the OneSignal native SDK falls back to
|
|
724
|
+
// its default behavior and displays the notification automatically.
|
|
725
|
+
if (!hasListeners("notificationForegroundWillDisplay")) return
|
|
721
726
|
// No retainUntilConsumed needed: foreground will-display only fires
|
|
722
727
|
// while the app is foregrounded, so the JS layer's listener is
|
|
723
728
|
// already attached. Contrast with onClick() below, which can fire
|
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ declare class Notifications implements OneSignalNotificationsAPI {
|
|
|
95
95
|
private _hasRegisteredClickListener;
|
|
96
96
|
private _hasRegisteredForegroundWillDisplayListener;
|
|
97
97
|
private _hasRegisteredPermissionListener;
|
|
98
|
+
private _foregroundWillDisplayListenerHandle?;
|
|
98
99
|
constructor(plugin: OneSignalCapacitorPlugin);
|
|
99
100
|
private _processFunctionList;
|
|
100
101
|
/**
|
package/dist/index.js
CHANGED
|
@@ -471,7 +471,7 @@ var Notifications = class {
|
|
|
471
471
|
this._notificationWillDisplayListeners.push(listener);
|
|
472
472
|
if (!this._hasRegisteredForegroundWillDisplayListener) {
|
|
473
473
|
this._hasRegisteredForegroundWillDisplayListener = true;
|
|
474
|
-
this._plugin.addListener("notificationForegroundWillDisplay", (notification) => {
|
|
474
|
+
this._foregroundWillDisplayListenerHandle = this._plugin.addListener("notificationForegroundWillDisplay", (notification) => {
|
|
475
475
|
this._notificationWillDisplayListeners.forEach((listener) => {
|
|
476
476
|
listener(new NotificationWillDisplayEvent(notification));
|
|
477
477
|
});
|
|
@@ -496,8 +496,15 @@ var Notifications = class {
|
|
|
496
496
|
*/
|
|
497
497
|
removeEventListener(event, listener) {
|
|
498
498
|
if (event === "click") removeListener(this._notificationClickedListeners, listener);
|
|
499
|
-
else if (event === "foregroundWillDisplay")
|
|
500
|
-
|
|
499
|
+
else if (event === "foregroundWillDisplay") {
|
|
500
|
+
removeListener(this._notificationWillDisplayListeners, listener);
|
|
501
|
+
if (this._notificationWillDisplayListeners.length === 0) {
|
|
502
|
+
this._hasRegisteredForegroundWillDisplayListener = false;
|
|
503
|
+
const listenerHandle = this._foregroundWillDisplayListenerHandle;
|
|
504
|
+
this._foregroundWillDisplayListenerHandle = void 0;
|
|
505
|
+
listenerHandle?.then((handle) => handle.remove());
|
|
506
|
+
}
|
|
507
|
+
} else if (event === "permissionChange") removeListener(this._permissionObserverList, listener);
|
|
501
508
|
}
|
|
502
509
|
/**
|
|
503
510
|
* Removes all OneSignal notifications.
|
|
@@ -110,7 +110,7 @@ public class OneSignalCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
110
110
|
initialized = true
|
|
111
111
|
|
|
112
112
|
OneSignalWrapper.sdkType = "capacitor"
|
|
113
|
-
OneSignalWrapper.sdkVersion = "
|
|
113
|
+
OneSignalWrapper.sdkVersion = "010004"
|
|
114
114
|
// OSCapacitorLaunchOptions's +load captures the dictionary from
|
|
115
115
|
// UIApplicationDidFinishLaunchingNotification at process start (before
|
|
116
116
|
// main()), so cold-start notification taps that arrive via launchOptions
|
|
@@ -616,6 +616,11 @@ public class OneSignalCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
public func onWillDisplay(event: OSNotificationWillDisplayEvent) {
|
|
619
|
+
// Match Cordova's default-display behavior: if no JS listener has
|
|
620
|
+
// subscribed via Notifications.addEventListener('foregroundWillDisplay'),
|
|
621
|
+
// leave the event untouched so the OneSignal native SDK falls back to
|
|
622
|
+
// its default behavior and displays the notification automatically.
|
|
623
|
+
guard hasListeners("notificationForegroundWillDisplay") else { return }
|
|
619
624
|
guard let notificationId = event.notification.notificationId else { return }
|
|
620
625
|
notificationWillDisplayCache[notificationId] = event
|
|
621
626
|
event.preventDefault()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onesignal/capacitor-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "OneSignal is a high volume Push Notification service for mobile apps. This is the pure Capacitor plugin for OneSignal, providing push notifications, in-app messaging, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apns",
|
|
@@ -62,15 +62,14 @@
|
|
|
62
62
|
"@vitest/coverage-v8": "^4.1.2",
|
|
63
63
|
"happy-dom": "^20.9.0",
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
66
65
|
"vite-plus": "0.1.20"
|
|
67
66
|
},
|
|
68
67
|
"peerDependencies": {
|
|
69
68
|
"@capacitor/core": ">=7.0.0"
|
|
70
69
|
},
|
|
71
70
|
"overrides": {
|
|
72
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@
|
|
73
|
-
"vitest": "npm:@voidzero-dev/vite-plus-test@
|
|
71
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
|
|
72
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.20"
|
|
74
73
|
},
|
|
75
74
|
"packageManager": "bun@1.3.13",
|
|
76
75
|
"capacitor": {
|