@onesignal/capacitor-plugin 1.0.5 → 1.0.6
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/OneSignalCapacitorPlugin.podspec +1 -1
- package/README.md +50 -16
- package/android/gradle/libs.versions.toml +1 -1
- package/android/src/main/kotlin/com/onesignal/capacitor/OneSignalCapacitorPlugin.kt +1 -19
- package/ios/Sources/OneSignalCapacitorPlugin/OneSignalCapacitorPlugin.swift +1 -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>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.onesignal.capacitor
|
|
2
2
|
|
|
3
|
-
import android.app.Application
|
|
4
3
|
import com.getcapacitor.JSObject
|
|
5
4
|
import com.getcapacitor.Plugin
|
|
6
5
|
import com.getcapacitor.PluginCall
|
|
@@ -8,7 +7,6 @@ import com.getcapacitor.PluginMethod
|
|
|
8
7
|
import com.getcapacitor.annotation.CapacitorPlugin
|
|
9
8
|
import com.onesignal.OneSignal
|
|
10
9
|
import com.onesignal.common.OneSignalWrapper
|
|
11
|
-
import com.onesignal.core.internal.application.IApplicationService
|
|
12
10
|
import com.onesignal.inAppMessages.IInAppMessageClickEvent
|
|
13
11
|
import com.onesignal.inAppMessages.IInAppMessageClickListener
|
|
14
12
|
import com.onesignal.inAppMessages.IInAppMessageDidDismissEvent
|
|
@@ -134,14 +132,9 @@ class OneSignalCapacitorPlugin : Plugin(),
|
|
|
134
132
|
initialized = true
|
|
135
133
|
|
|
136
134
|
OneSignalWrapper.sdkType = "capacitor"
|
|
137
|
-
OneSignalWrapper.sdkVersion = "
|
|
135
|
+
OneSignalWrapper.sdkVersion = "010006"
|
|
138
136
|
OneSignal.initWithContext(context, appId)
|
|
139
137
|
|
|
140
|
-
// If the SDK was initialized from a non-Activity context (FCM/work
|
|
141
|
-
// managers) before this call, its ALC missed MainActivity.onResume
|
|
142
|
-
// and isInForeground stays false. Forward the missed events now.
|
|
143
|
-
nudgeApplicationServiceForeground()
|
|
144
|
-
|
|
145
138
|
OneSignal.Notifications.addPermissionObserver(permissionObserver)
|
|
146
139
|
OneSignal.Notifications.addForegroundLifecycleListener(this)
|
|
147
140
|
OneSignal.Notifications.addClickListener(this)
|
|
@@ -153,17 +146,6 @@ class OneSignalCapacitorPlugin : Plugin(),
|
|
|
153
146
|
call.resolve()
|
|
154
147
|
}
|
|
155
148
|
|
|
156
|
-
/** Forward the missed activity-resume to the SDK so isInForeground is
|
|
157
|
-
* correct on cold start. No-op if the SDK already saw the resume. */
|
|
158
|
-
private fun nudgeApplicationServiceForeground() {
|
|
159
|
-
val activity = activity ?: return
|
|
160
|
-
val appSvc = runCatching { OneSignal.getServiceOrNull<IApplicationService>() }.getOrNull() ?: return
|
|
161
|
-
if (appSvc.isInForeground && appSvc.current === activity) return
|
|
162
|
-
val callbacks = appSvc as? Application.ActivityLifecycleCallbacks ?: return
|
|
163
|
-
callbacks.onActivityStarted(activity)
|
|
164
|
-
callbacks.onActivityResumed(activity)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
149
|
private fun buildClickEventJson(event: INotificationClickEvent): JSObject {
|
|
168
150
|
val ret = JSObject()
|
|
169
151
|
val clickResult = JSObject()
|
|
@@ -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 = "010006"
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onesignal/capacitor-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
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",
|