@onesignal/capacitor-plugin 1.0.3 → 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/README.md +50 -16
- package/android/build.gradle.kts +23 -16
- package/android/gradle/libs.versions.toml +22 -11
- 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 +1 -1
package/README.md
CHANGED
|
@@ -24,13 +24,13 @@ See the `examples/demo` directory for a full working example.
|
|
|
24
24
|
|
|
25
25
|
<docgen-index>
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
* [`initialize(...)`](#initialize)
|
|
28
|
+
* [`login(...)`](#login)
|
|
29
|
+
* [`logout()`](#logout)
|
|
30
|
+
* [`setConsentRequired(...)`](#setconsentrequired)
|
|
31
|
+
* [`setConsentGiven(...)`](#setconsentgiven)
|
|
32
|
+
* [Interfaces](#interfaces)
|
|
33
|
+
* [Type Aliases](#type-aliases)
|
|
34
34
|
|
|
35
35
|
</docgen-index>
|
|
36
36
|
|
|
@@ -51,7 +51,8 @@ Initialize the SDK with your OneSignal app ID. Call during app startup.
|
|
|
51
51
|
| ----------- | ------------------- |
|
|
52
52
|
| **`appId`** | <code>string</code> |
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
--------------------
|
|
55
|
+
|
|
55
56
|
|
|
56
57
|
### login(...)
|
|
57
58
|
|
|
@@ -65,7 +66,8 @@ Log in to OneSignal as the user identified by `externalId`, switching the user c
|
|
|
65
66
|
| ---------------- | ------------------- |
|
|
66
67
|
| **`externalId`** | <code>string</code> |
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
--------------------
|
|
70
|
+
|
|
69
71
|
|
|
70
72
|
### logout()
|
|
71
73
|
|
|
@@ -75,7 +77,8 @@ logout() => Promise<void>
|
|
|
75
77
|
|
|
76
78
|
Log out the current user. The SDK will reference a new device-scoped user.
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
--------------------
|
|
81
|
+
|
|
79
82
|
|
|
80
83
|
### setConsentRequired(...)
|
|
81
84
|
|
|
@@ -89,7 +92,8 @@ Set whether user privacy consent is required before sending data to OneSignal. C
|
|
|
89
92
|
| -------------- | -------------------- |
|
|
90
93
|
| **`required`** | <code>boolean</code> |
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
--------------------
|
|
96
|
+
|
|
93
97
|
|
|
94
98
|
### setConsentGiven(...)
|
|
95
99
|
|
|
@@ -103,10 +107,12 @@ Indicate whether the user has granted privacy consent.
|
|
|
103
107
|
| ------------- | -------------------- |
|
|
104
108
|
| **`granted`** | <code>boolean</code> |
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
--------------------
|
|
111
|
+
|
|
107
112
|
|
|
108
113
|
### Interfaces
|
|
109
114
|
|
|
115
|
+
|
|
110
116
|
#### OneSignalDebugAPI
|
|
111
117
|
|
|
112
118
|
Debug helpers exposed via `OneSignal.Debug`.
|
|
@@ -116,6 +122,7 @@ Debug helpers exposed via `OneSignal.Debug`.
|
|
|
116
122
|
| **setLogLevel** | (logLevel: <a href="#loglevel">LogLevel</a>) => void | Set the log level printed to LogCat (Android) or the Xcode console (iOS). |
|
|
117
123
|
| **setAlertLevel** | (visualLogLevel: <a href="#loglevel">LogLevel</a>) => void | Set the log level shown to the user as alert dialogs. |
|
|
118
124
|
|
|
125
|
+
|
|
119
126
|
#### OneSignalUserAPI
|
|
120
127
|
|
|
121
128
|
Current-user operations exposed via `OneSignal.User`.
|
|
@@ -146,12 +153,14 @@ Current-user operations exposed via `OneSignal.User`.
|
|
|
146
153
|
| **getExternalId** | () => Promise<string \| null> | Get the external ID set via `login`, or null if the user is anonymous. |
|
|
147
154
|
| **trackEvent** | (name: string, properties?: object \| undefined) => Promise<void> | Track a custom event with an optional set of JSON-serializable properties. |
|
|
148
155
|
|
|
156
|
+
|
|
149
157
|
#### UserChangedState
|
|
150
158
|
|
|
151
159
|
| Prop | Type |
|
|
152
160
|
| ------------- | ----------------------------------------------- |
|
|
153
161
|
| **`current`** | <code><a href="#userstate">UserState</a></code> |
|
|
154
162
|
|
|
163
|
+
|
|
155
164
|
#### UserState
|
|
156
165
|
|
|
157
166
|
| Prop | Type |
|
|
@@ -159,6 +168,7 @@ Current-user operations exposed via `OneSignal.User`.
|
|
|
159
168
|
| **`onesignalId`** | <code>string</code> |
|
|
160
169
|
| **`externalId`** | <code>string</code> |
|
|
161
170
|
|
|
171
|
+
|
|
162
172
|
#### OneSignalPushSubscriptionAPI
|
|
163
173
|
|
|
164
174
|
Push subscription state and controls exposed via `OneSignal.User.pushSubscription`.
|
|
@@ -173,6 +183,7 @@ Push subscription state and controls exposed via `OneSignal.User.pushSubscriptio
|
|
|
173
183
|
| **optIn** | () => Promise<void> | Opt the user in to push notifications. Prompts for permission if needed. |
|
|
174
184
|
| **optOut** | () => Promise<void> | Opt the user out of push notifications on this device. |
|
|
175
185
|
|
|
186
|
+
|
|
176
187
|
#### PushSubscriptionChangedState
|
|
177
188
|
|
|
178
189
|
| Prop | Type |
|
|
@@ -180,6 +191,7 @@ Push subscription state and controls exposed via `OneSignal.User.pushSubscriptio
|
|
|
180
191
|
| **`previous`** | <code><a href="#pushsubscriptionstate">PushSubscriptionState</a></code> |
|
|
181
192
|
| **`current`** | <code><a href="#pushsubscriptionstate">PushSubscriptionState</a></code> |
|
|
182
193
|
|
|
194
|
+
|
|
183
195
|
#### PushSubscriptionState
|
|
184
196
|
|
|
185
197
|
| Prop | Type |
|
|
@@ -188,6 +200,7 @@ Push subscription state and controls exposed via `OneSignal.User.pushSubscriptio
|
|
|
188
200
|
| **`token`** | <code>string</code> |
|
|
189
201
|
| **`optedIn`** | <code>boolean</code> |
|
|
190
202
|
|
|
203
|
+
|
|
191
204
|
#### OneSignalNotificationsAPI
|
|
192
205
|
|
|
193
206
|
Notification permission and event handling exposed via `OneSignal.Notifications`.
|
|
@@ -205,6 +218,7 @@ Notification permission and event handling exposed via `OneSignal.Notifications`
|
|
|
205
218
|
| **removeNotification** | (id: number) => Promise<void> | Android only. Cancel a single notification by its Android notification ID. |
|
|
206
219
|
| **removeGroupedNotifications** | (id: string) => Promise<void> | Android only. Cancel a group of notifications by group key. |
|
|
207
220
|
|
|
221
|
+
|
|
208
222
|
#### NotificationClickEvent
|
|
209
223
|
|
|
210
224
|
| Prop | Type |
|
|
@@ -212,6 +226,7 @@ Notification permission and event handling exposed via `OneSignal.Notifications`
|
|
|
212
226
|
| **`result`** | <code><a href="#notificationclickresult">NotificationClickResult</a></code> |
|
|
213
227
|
| **`notification`** | <code>OSNotification</code> |
|
|
214
228
|
|
|
229
|
+
|
|
215
230
|
#### NotificationClickResult
|
|
216
231
|
|
|
217
232
|
| Prop | Type |
|
|
@@ -219,6 +234,7 @@ Notification permission and event handling exposed via `OneSignal.Notifications`
|
|
|
219
234
|
| **`actionId`** | <code>string</code> |
|
|
220
235
|
| **`url`** | <code>string</code> |
|
|
221
236
|
|
|
237
|
+
|
|
222
238
|
#### OneSignalInAppMessagesAPI
|
|
223
239
|
|
|
224
240
|
In-app message triggers and event handling exposed via `OneSignal.InAppMessages`.
|
|
@@ -235,6 +251,7 @@ In-app message triggers and event handling exposed via `OneSignal.InAppMessages`
|
|
|
235
251
|
| **setPaused** | (pause: boolean) => void | Pause or resume the display of in-app messages. |
|
|
236
252
|
| **getPaused** | () => Promise<boolean> | Whether in-app messaging is currently paused. |
|
|
237
253
|
|
|
254
|
+
|
|
238
255
|
#### InAppMessageClickEvent
|
|
239
256
|
|
|
240
257
|
| Prop | Type |
|
|
@@ -242,12 +259,14 @@ In-app message triggers and event handling exposed via `OneSignal.InAppMessages`
|
|
|
242
259
|
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
|
|
243
260
|
| **`result`** | <code><a href="#inappmessageclickresult">InAppMessageClickResult</a></code> |
|
|
244
261
|
|
|
262
|
+
|
|
245
263
|
#### OSInAppMessage
|
|
246
264
|
|
|
247
265
|
| Prop | Type |
|
|
248
266
|
| --------------- | ------------------- |
|
|
249
267
|
| **`messageId`** | <code>string</code> |
|
|
250
268
|
|
|
269
|
+
|
|
251
270
|
#### InAppMessageClickResult
|
|
252
271
|
|
|
253
272
|
| Prop | Type |
|
|
@@ -257,30 +276,35 @@ In-app message triggers and event handling exposed via `OneSignal.InAppMessages`
|
|
|
257
276
|
| **`url`** | <code>string</code> |
|
|
258
277
|
| **`urlTarget`** | <code><a href="#inappmessageactionurltype">InAppMessageActionUrlType</a></code> |
|
|
259
278
|
|
|
279
|
+
|
|
260
280
|
#### InAppMessageWillDisplayEvent
|
|
261
281
|
|
|
262
282
|
| Prop | Type |
|
|
263
283
|
| ------------- | --------------------------------------------------------- |
|
|
264
284
|
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
|
|
265
285
|
|
|
286
|
+
|
|
266
287
|
#### InAppMessageDidDisplayEvent
|
|
267
288
|
|
|
268
289
|
| Prop | Type |
|
|
269
290
|
| ------------- | --------------------------------------------------------- |
|
|
270
291
|
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
|
|
271
292
|
|
|
293
|
+
|
|
272
294
|
#### InAppMessageWillDismissEvent
|
|
273
295
|
|
|
274
296
|
| Prop | Type |
|
|
275
297
|
| ------------- | --------------------------------------------------------- |
|
|
276
298
|
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
|
|
277
299
|
|
|
300
|
+
|
|
278
301
|
#### InAppMessageDidDismissEvent
|
|
279
302
|
|
|
280
303
|
| Prop | Type |
|
|
281
304
|
| ------------- | --------------------------------------------------------- |
|
|
282
305
|
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
|
|
283
306
|
|
|
307
|
+
|
|
284
308
|
#### OneSignalSessionAPI
|
|
285
309
|
|
|
286
310
|
Outcome reporting exposed via `OneSignal.Session`.
|
|
@@ -291,6 +315,7 @@ Outcome reporting exposed via `OneSignal.Session`.
|
|
|
291
315
|
| **addUniqueOutcome** | (name: string) => Promise<void> | <a href="#record">Record</a> a unique outcome with the given name against the current session. |
|
|
292
316
|
| **addOutcomeWithValue** | (name: string, value: number) => Promise<void> | <a href="#record">Record</a> an outcome with the given name and value against the current session. |
|
|
293
317
|
|
|
318
|
+
|
|
294
319
|
#### OneSignalLocationAPI
|
|
295
320
|
|
|
296
321
|
Location permission and sharing exposed via `OneSignal.Location`.
|
|
@@ -301,6 +326,7 @@ Location permission and sharing exposed via `OneSignal.Location`.
|
|
|
301
326
|
| **setShared** | (shared: boolean) => void | Enable or disable sharing the device location with OneSignal. |
|
|
302
327
|
| **isShared** | () => Promise<boolean> | Whether the device location is currently shared with OneSignal. |
|
|
303
328
|
|
|
329
|
+
|
|
304
330
|
#### OneSignalLiveActivitiesAPI
|
|
305
331
|
|
|
306
332
|
Live activity controls exposed via `OneSignal.LiveActivities`. iOS only unless noted.
|
|
@@ -314,48 +340,56 @@ Live activity controls exposed via `OneSignal.LiveActivities`. iOS only unless n
|
|
|
314
340
|
| **setupDefault** | (options?: <a href="#liveactivitysetupoptions">LiveActivitySetupOptions</a> \| undefined) => Promise<void> | Set up the OneSignal default live activity, optionally enabling pushToStart/pushToUpdate. |
|
|
315
341
|
| **startDefault** | (activityId: string, attributes: <a href="#record">Record</a><string, unknown>, content: <a href="#record">Record</a><string, unknown>) => Promise<void> | Start a live activity backed by the OneSignal default attributes type. |
|
|
316
342
|
|
|
343
|
+
|
|
317
344
|
### Type Aliases
|
|
318
345
|
|
|
346
|
+
|
|
319
347
|
#### LogLevel
|
|
320
348
|
|
|
321
349
|
<code>(typeof <a href="#loglevel">LogLevel</a>)[keyof typeof LogLevel]</code>
|
|
322
350
|
|
|
351
|
+
|
|
323
352
|
#### Record
|
|
324
353
|
|
|
325
354
|
Construct a type with a set of properties K of type T
|
|
326
355
|
|
|
327
|
-
<code>{
|
|
328
|
-
[P in K]: T;
|
|
329
|
-
}</code>
|
|
356
|
+
<code>{
|
|
330
357
|
[P in K]: T;
|
|
331
358
|
}</code>
|
|
359
|
+
|
|
332
360
|
|
|
333
361
|
#### OSNotificationPermission
|
|
334
362
|
|
|
335
363
|
<code>(typeof <a href="#osnotificationpermission">OSNotificationPermission</a>)[keyof typeof OSNotificationPermission]</code>
|
|
336
364
|
|
|
365
|
+
|
|
337
366
|
#### NotificationEventName
|
|
338
367
|
|
|
339
368
|
<code>'click' | 'foregroundWillDisplay' | 'permissionChange'</code>
|
|
340
369
|
|
|
370
|
+
|
|
341
371
|
#### NotificationEventTypeMap
|
|
342
372
|
|
|
343
373
|
<code>{ click: <a href="#notificationclickevent">NotificationClickEvent</a>; foregroundWillDisplay: NotificationWillDisplayEvent; permissionChange: boolean; }</code>
|
|
344
374
|
|
|
375
|
+
|
|
345
376
|
#### InAppMessageEventName
|
|
346
377
|
|
|
347
378
|
<code>'click' | 'willDisplay' | 'didDisplay' | 'willDismiss' | 'didDismiss'</code>
|
|
348
379
|
|
|
380
|
+
|
|
349
381
|
#### InAppMessageEventTypeMap
|
|
350
382
|
|
|
351
383
|
<code>{ click: <a href="#inappmessageclickevent">InAppMessageClickEvent</a>; willDisplay: <a href="#inappmessagewilldisplayevent">InAppMessageWillDisplayEvent</a>; didDisplay: <a href="#inappmessagediddisplayevent">InAppMessageDidDisplayEvent</a>; willDismiss: <a href="#inappmessagewilldismissevent">InAppMessageWillDismissEvent</a>; didDismiss: <a href="#inappmessagediddismissevent">InAppMessageDidDismissEvent</a>; }</code>
|
|
352
384
|
|
|
385
|
+
|
|
353
386
|
#### InAppMessageActionUrlType
|
|
354
387
|
|
|
355
388
|
<code>'browser' | 'webview' | 'replacement'</code>
|
|
356
389
|
|
|
390
|
+
|
|
357
391
|
#### LiveActivitySetupOptions
|
|
358
392
|
|
|
359
393
|
The setup options for `OneSignal.LiveActivities.setupDefault`.
|
|
360
394
|
|
|
361
|
-
<code>{ /**
|
|
395
|
+
<code>{ /** * When true, OneSignal will listen for pushToStart tokens for the `OneSignalLiveActivityAttributes` structure. */ enablePushToStart: boolean; /** * When true, OneSignal will listen for pushToUpdate tokens for each start live activity that uses the * `OneSignalLiveActivityAttributes` structure. */ enablePushToUpdate: boolean; }</code>
|
|
362
396
|
|
|
363
397
|
</docgen-api>
|
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 = "
|
|
26
|
+
kotlin = "2.2.20"
|
|
27
|
+
minSdk = "24"
|
|
17
28
|
onesignal = "5.9.1"
|
|
18
|
-
targetSdk = "
|
|
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",
|