@onesignal/capacitor-plugin 1.0.0

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.
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'OnesignalCapacitorPlugin'
7
+ s.version = package['version']
8
+ s.summary = 'OneSignal Push Notifications Capacitor Plugin'
9
+ s.license = package['license']
10
+ s.homepage = package['homepage']
11
+ s.author = 'OneSignal'
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/OneSignalCapacitorPlugin/**/*.swift'
14
+
15
+ s.ios.deployment_target = '14.0'
16
+ s.swift_version = '5.9'
17
+
18
+ s.dependency 'Capacitor'
19
+ s.dependency 'OneSignalXCFramework', '5.5.0'
20
+ end
package/Package.swift ADDED
@@ -0,0 +1,36 @@
1
+ // swift-tools-version: 5.9
2
+
3
+ import PackageDescription
4
+
5
+ let package = Package(
6
+ name: "OnesignalCapacitorPlugin",
7
+ platforms: [.iOS(.v14)],
8
+ products: [
9
+ .library(
10
+ name: "OnesignalCapacitorPlugin",
11
+ targets: ["OnesignalCapacitorPlugin"]
12
+ )
13
+ ],
14
+ dependencies: [
15
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", "7.0.0"..<"9.0.0"),
16
+ .package(url: "https://github.com/OneSignal/OneSignal-XCFramework", from: "5.0.0")
17
+ ],
18
+ targets: [
19
+ .target(
20
+ name: "OnesignalCapacitorPlugin",
21
+ dependencies: [
22
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
23
+ .product(name: "Cordova", package: "capacitor-swift-pm"),
24
+ // InAppMessages and Location are separate library products in
25
+ // OneSignal-XCFramework and must be linked explicitly under SPM,
26
+ // otherwise their xcframeworks aren't loaded and the namespaces
27
+ // are silent no-ops at runtime.
28
+ .product(name: "OneSignalFramework", package: "OneSignal-XCFramework"),
29
+ .product(name: "OneSignalInAppMessages", package: "OneSignal-XCFramework"),
30
+ .product(name: "OneSignalLocation", package: "OneSignal-XCFramework"),
31
+ .product(name: "OneSignalExtension", package: "OneSignal-XCFramework")
32
+ ],
33
+ path: "ios/Sources/OneSignalCapacitorPlugin"
34
+ )
35
+ ]
36
+ )
package/README.md ADDED
@@ -0,0 +1,361 @@
1
+ # OneSignal-Capacitor-SDK
2
+
3
+ The pure [Capacitor](https://capacitorjs.com/) plugin for [OneSignal](https://onesignal.com/), providing push notifications, in-app messaging, live activities, and more.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @onesignal/capacitor-plugin
9
+ npx cap sync
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```ts
15
+ import OneSignal from '@onesignal/capacitor-plugin';
16
+
17
+ await OneSignal.initialize({ appId: 'YOUR_ONESIGNAL_APP_ID' });
18
+ await OneSignal.Notifications.requestPermission(true);
19
+ ```
20
+
21
+ See the `examples/demo` directory for a full working example.
22
+
23
+ ## API
24
+
25
+ <docgen-index>
26
+
27
+ - [`initialize(...)`](#initialize)
28
+ - [`login(...)`](#login)
29
+ - [`logout()`](#logout)
30
+ - [`setConsentRequired(...)`](#setconsentrequired)
31
+ - [`setConsentGiven(...)`](#setconsentgiven)
32
+ - [Interfaces](#interfaces)
33
+ - [Type Aliases](#type-aliases)
34
+
35
+ </docgen-index>
36
+
37
+ <docgen-api>
38
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
39
+
40
+ The public OneSignal Capacitor plugin API. This is the shape of the default `OneSignal` export.
41
+
42
+ ### initialize(...)
43
+
44
+ ```typescript
45
+ initialize(appId: string) => Promise<void>
46
+ ```
47
+
48
+ Initialize the SDK with your OneSignal app ID. Call during app startup.
49
+
50
+ | Param | Type |
51
+ | ----------- | ------------------- |
52
+ | **`appId`** | <code>string</code> |
53
+
54
+ ---
55
+
56
+ ### login(...)
57
+
58
+ ```typescript
59
+ login(externalId: string) => Promise<void>
60
+ ```
61
+
62
+ Log in to OneSignal as the user identified by `externalId`, switching the user context.
63
+
64
+ | Param | Type |
65
+ | ---------------- | ------------------- |
66
+ | **`externalId`** | <code>string</code> |
67
+
68
+ ---
69
+
70
+ ### logout()
71
+
72
+ ```typescript
73
+ logout() => Promise<void>
74
+ ```
75
+
76
+ Log out the current user. The SDK will reference a new device-scoped user.
77
+
78
+ ---
79
+
80
+ ### setConsentRequired(...)
81
+
82
+ ```typescript
83
+ setConsentRequired(required: boolean) => void
84
+ ```
85
+
86
+ Set whether user privacy consent is required before sending data to OneSignal. Call before `initialize`.
87
+
88
+ | Param | Type |
89
+ | -------------- | -------------------- |
90
+ | **`required`** | <code>boolean</code> |
91
+
92
+ ---
93
+
94
+ ### setConsentGiven(...)
95
+
96
+ ```typescript
97
+ setConsentGiven(granted: boolean) => void
98
+ ```
99
+
100
+ Indicate whether the user has granted privacy consent.
101
+
102
+ | Param | Type |
103
+ | ------------- | -------------------- |
104
+ | **`granted`** | <code>boolean</code> |
105
+
106
+ ---
107
+
108
+ ### Interfaces
109
+
110
+ #### OneSignalDebugAPI
111
+
112
+ Debug helpers exposed via `OneSignal.Debug`.
113
+
114
+ | Method | Signature | Description |
115
+ | ----------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------- |
116
+ | **setLogLevel** | (logLevel: <a href="#loglevel">LogLevel</a>) =&gt; void | Set the log level printed to LogCat (Android) or the Xcode console (iOS). |
117
+ | **setAlertLevel** | (visualLogLevel: <a href="#loglevel">LogLevel</a>) =&gt; void | Set the log level shown to the user as alert dialogs. |
118
+
119
+ #### OneSignalUserAPI
120
+
121
+ Current-user operations exposed via `OneSignal.User`.
122
+
123
+ | Prop | Type | Description |
124
+ | ---------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------ |
125
+ | **`pushSubscription`** | <code><a href="#onesignalpushsubscriptionapi">OneSignalPushSubscriptionAPI</a></code> | Push subscription controls for the current user. |
126
+
127
+ | Method | Signature | Description |
128
+ | ----------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
129
+ | **setLanguage** | (language: string) =&gt; Promise&lt;void&gt; | Explicitly set a 2-character language code for the current user. |
130
+ | **addAlias** | (label: string, id: string) =&gt; Promise&lt;void&gt; | Add or overwrite a single alias on the current user. |
131
+ | **addAliases** | (aliases: <a href="#record">Record</a>&lt;string, string&gt;) =&gt; Promise&lt;void&gt; | Add or overwrite multiple aliases on the current user. |
132
+ | **removeAlias** | (label: string) =&gt; Promise&lt;void&gt; | Remove a single alias by label from the current user. |
133
+ | **removeAliases** | (labels: string[]) =&gt; Promise&lt;void&gt; | Remove multiple aliases by label from the current user. |
134
+ | **addEmail** | (email: string) =&gt; Promise&lt;void&gt; | Add a new email subscription to the current user. |
135
+ | **removeEmail** | (email: string) =&gt; Promise&lt;void&gt; | Remove an email subscription from the current user. |
136
+ | **addSms** | (smsNumber: string) =&gt; Promise&lt;void&gt; | Add a new SMS subscription to the current user. |
137
+ | **removeSms** | (smsNumber: string) =&gt; Promise&lt;void&gt; | Remove an SMS subscription from the current user. |
138
+ | **addTag** | (key: string, value: string) =&gt; Promise&lt;void&gt; | Add a single tag (key/value) on the current user, used for targeting and personalization. |
139
+ | **addTags** | (tags: object) =&gt; Promise&lt;void&gt; | Add or overwrite multiple tags on the current user. |
140
+ | **removeTag** | (key: string) =&gt; Promise&lt;void&gt; | Remove a single tag by key from the current user. |
141
+ | **removeTags** | (keys: string[]) =&gt; Promise&lt;void&gt; | Remove multiple tags by key from the current user. |
142
+ | **getTags** | () =&gt; Promise&lt;{ [key: string]: string; }&gt; | Get the local tags for the current user. |
143
+ | **addEventListener** | (event: 'change', listener: (event: <a href="#userchangedstate">UserChangedState</a>) =&gt; void) =&gt; void | Add a listener for OneSignal user state changes. |
144
+ | **removeEventListener** | (event: 'change', listener: (event: <a href="#userchangedstate">UserChangedState</a>) =&gt; void) =&gt; void | Remove a previously added user state listener. |
145
+ | **getOnesignalId** | () =&gt; Promise&lt;string \| null&gt; | Get the OneSignal-assigned ID for the current user, or null if not yet available. |
146
+ | **getExternalId** | () =&gt; Promise&lt;string \| null&gt; | Get the external ID set via `login`, or null if the user is anonymous. |
147
+ | **trackEvent** | (name: string, properties?: object \| undefined) =&gt; Promise&lt;void&gt; | Track a custom event with an optional set of JSON-serializable properties. |
148
+
149
+ #### UserChangedState
150
+
151
+ | Prop | Type |
152
+ | ------------- | ----------------------------------------------- |
153
+ | **`current`** | <code><a href="#userstate">UserState</a></code> |
154
+
155
+ #### UserState
156
+
157
+ | Prop | Type |
158
+ | ----------------- | ------------------- |
159
+ | **`onesignalId`** | <code>string</code> |
160
+ | **`externalId`** | <code>string</code> |
161
+
162
+ #### OneSignalPushSubscriptionAPI
163
+
164
+ Push subscription state and controls exposed via `OneSignal.User.pushSubscription`.
165
+
166
+ | Method | Signature | Description |
167
+ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
168
+ | **getIdAsync** | () =&gt; Promise&lt;string \| null&gt; | Get the current device's push subscription ID, or null if not yet assigned. |
169
+ | **getTokenAsync** | () =&gt; Promise&lt;string \| null&gt; | Get the current device's push token, or null if not yet available. |
170
+ | **getOptedInAsync** | () =&gt; Promise&lt;boolean&gt; | Whether the current user is opted in to push notifications. Returns true when the app has notification permission and `optOut()` has not been called. Does not guarantee a token has been received. |
171
+ | **addEventListener** | (event: 'change', listener: (event: <a href="#pushsubscriptionchangedstate">PushSubscriptionChangedState</a>) =&gt; void) =&gt; void | Add a listener for push subscription state changes. |
172
+ | **removeEventListener** | (event: 'change', listener: (event: <a href="#pushsubscriptionchangedstate">PushSubscriptionChangedState</a>) =&gt; void) =&gt; void | Remove a previously added push subscription state listener. |
173
+ | **optIn** | () =&gt; Promise&lt;void&gt; | Opt the user in to push notifications. Prompts for permission if needed. |
174
+ | **optOut** | () =&gt; Promise&lt;void&gt; | Opt the user out of push notifications on this device. |
175
+
176
+ #### PushSubscriptionChangedState
177
+
178
+ | Prop | Type |
179
+ | -------------- | ----------------------------------------------------------------------- |
180
+ | **`previous`** | <code><a href="#pushsubscriptionstate">PushSubscriptionState</a></code> |
181
+ | **`current`** | <code><a href="#pushsubscriptionstate">PushSubscriptionState</a></code> |
182
+
183
+ #### PushSubscriptionState
184
+
185
+ | Prop | Type |
186
+ | ------------- | -------------------- |
187
+ | **`id`** | <code>string</code> |
188
+ | **`token`** | <code>string</code> |
189
+ | **`optedIn`** | <code>boolean</code> |
190
+
191
+ #### OneSignalNotificationsAPI
192
+
193
+ Notification permission and event handling exposed via `OneSignal.Notifications`.
194
+
195
+ | Method | Signature | Description |
196
+ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
197
+ | **hasPermission** | () =&gt; Promise&lt;boolean&gt; | Whether the app currently has notification permission (including provisional/ephemeral). |
198
+ | **permissionNative** | () =&gt; Promise&lt;<a href="#osnotificationpermission">OSNotificationPermission</a>&gt; | iOS only. The native notification permission status. |
199
+ | **requestPermission** | (fallbackToSettings?: boolean \| undefined) =&gt; Promise&lt;boolean&gt; | Prompt the user for notification permission. Optionally fall back to system settings. |
200
+ | **canRequestPermission** | () =&gt; Promise&lt;boolean&gt; | Whether requesting notification permission would still show a prompt. |
201
+ | **registerForProvisionalAuthorization** | (handler?: ((response: boolean) =&gt; void) \| undefined) =&gt; void | iOS only. Request provisional authorization for quiet notifications without prompting. |
202
+ | **addEventListener** | &lt;K extends <a href="#notificationeventname">NotificationEventName</a>&gt;(event: K, listener: (event: NotificationEventTypeMap[K]) =&gt; void) =&gt; void | Add a listener for `click`, `foregroundWillDisplay`, or `permissionChange` events. |
203
+ | **removeEventListener** | &lt;K extends <a href="#notificationeventname">NotificationEventName</a>&gt;(event: K, listener: (obj: NotificationEventTypeMap[K]) =&gt; void) =&gt; void | Remove a previously added notification event listener. |
204
+ | **clearAll** | () =&gt; Promise&lt;void&gt; | Remove all OneSignal notifications from the notification center. |
205
+ | **removeNotification** | (id: number) =&gt; Promise&lt;void&gt; | Android only. Cancel a single notification by its Android notification ID. |
206
+ | **removeGroupedNotifications** | (id: string) =&gt; Promise&lt;void&gt; | Android only. Cancel a group of notifications by group key. |
207
+
208
+ #### NotificationClickEvent
209
+
210
+ | Prop | Type |
211
+ | ------------------ | --------------------------------------------------------------------------- |
212
+ | **`result`** | <code><a href="#notificationclickresult">NotificationClickResult</a></code> |
213
+ | **`notification`** | <code>OSNotification</code> |
214
+
215
+ #### NotificationClickResult
216
+
217
+ | Prop | Type |
218
+ | -------------- | ------------------- |
219
+ | **`actionId`** | <code>string</code> |
220
+ | **`url`** | <code>string</code> |
221
+
222
+ #### OneSignalInAppMessagesAPI
223
+
224
+ In-app message triggers and event handling exposed via `OneSignal.InAppMessages`.
225
+
226
+ | Method | Signature | Description |
227
+ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
228
+ | **addEventListener** | &lt;K extends <a href="#inappmessageeventname">InAppMessageEventName</a>&gt;(event: K, listener: (event: InAppMessageEventTypeMap[K]) =&gt; void) =&gt; void | Add a listener for IAM `click`, `willDisplay`, `didDisplay`, `willDismiss`, or `didDismiss` events. |
229
+ | **removeEventListener** | &lt;K extends <a href="#inappmessageeventname">InAppMessageEventName</a>&gt;(event: K, listener: (obj: InAppMessageEventTypeMap[K]) =&gt; void) =&gt; void | Remove a previously added IAM event listener. |
230
+ | **addTrigger** | (key: string, value: string) =&gt; Promise&lt;void&gt; | Add a single trigger (key/value) used to determine which IAMs are displayed to the user. |
231
+ | **addTriggers** | (triggers: { [key: string]: string; }) =&gt; Promise&lt;void&gt; | Add or overwrite multiple triggers for the current user. |
232
+ | **removeTrigger** | (key: string) =&gt; Promise&lt;void&gt; | Remove a single trigger by key. |
233
+ | **removeTriggers** | (keys: string[]) =&gt; Promise&lt;void&gt; | Remove multiple triggers by key. |
234
+ | **clearTriggers** | () =&gt; Promise&lt;void&gt; | Clear all triggers from the current user. |
235
+ | **setPaused** | (pause: boolean) =&gt; void | Pause or resume the display of in-app messages. |
236
+ | **getPaused** | () =&gt; Promise&lt;boolean&gt; | Whether in-app messaging is currently paused. |
237
+
238
+ #### InAppMessageClickEvent
239
+
240
+ | Prop | Type |
241
+ | ------------- | --------------------------------------------------------------------------- |
242
+ | **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
243
+ | **`result`** | <code><a href="#inappmessageclickresult">InAppMessageClickResult</a></code> |
244
+
245
+ #### OSInAppMessage
246
+
247
+ | Prop | Type |
248
+ | --------------- | ------------------- |
249
+ | **`messageId`** | <code>string</code> |
250
+
251
+ #### InAppMessageClickResult
252
+
253
+ | Prop | Type |
254
+ | -------------------- | ------------------------------------------------------------------------------- |
255
+ | **`closingMessage`** | <code>boolean</code> |
256
+ | **`actionId`** | <code>string</code> |
257
+ | **`url`** | <code>string</code> |
258
+ | **`urlTarget`** | <code><a href="#inappmessageactionurltype">InAppMessageActionUrlType</a></code> |
259
+
260
+ #### InAppMessageWillDisplayEvent
261
+
262
+ | Prop | Type |
263
+ | ------------- | --------------------------------------------------------- |
264
+ | **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
265
+
266
+ #### InAppMessageDidDisplayEvent
267
+
268
+ | Prop | Type |
269
+ | ------------- | --------------------------------------------------------- |
270
+ | **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
271
+
272
+ #### InAppMessageWillDismissEvent
273
+
274
+ | Prop | Type |
275
+ | ------------- | --------------------------------------------------------- |
276
+ | **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
277
+
278
+ #### InAppMessageDidDismissEvent
279
+
280
+ | Prop | Type |
281
+ | ------------- | --------------------------------------------------------- |
282
+ | **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
283
+
284
+ #### OneSignalSessionAPI
285
+
286
+ Outcome reporting exposed via `OneSignal.Session`.
287
+
288
+ | Method | Signature | Description |
289
+ | ----------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
290
+ | **addOutcome** | (name: string) =&gt; Promise&lt;void&gt; | <a href="#record">Record</a> an outcome with the given name against the current session. |
291
+ | **addUniqueOutcome** | (name: string) =&gt; Promise&lt;void&gt; | <a href="#record">Record</a> a unique outcome with the given name against the current session. |
292
+ | **addOutcomeWithValue** | (name: string, value: number) =&gt; Promise&lt;void&gt; | <a href="#record">Record</a> an outcome with the given name and value against the current session. |
293
+
294
+ #### OneSignalLocationAPI
295
+
296
+ Location permission and sharing exposed via `OneSignal.Location`.
297
+
298
+ | Method | Signature | Description |
299
+ | --------------------- | ------------------------------- | --------------------------------------------------------------- |
300
+ | **requestPermission** | () =&gt; Promise&lt;void&gt; | Prompt the user for location permission to enable geotagging. |
301
+ | **setShared** | (shared: boolean) =&gt; void | Enable or disable sharing the device location with OneSignal. |
302
+ | **isShared** | () =&gt; Promise&lt;boolean&gt; | Whether the device location is currently shared with OneSignal. |
303
+
304
+ #### OneSignalLiveActivitiesAPI
305
+
306
+ Live activity controls exposed via `OneSignal.LiveActivities`. iOS only unless noted.
307
+
308
+ | Method | Signature | Description |
309
+ | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
310
+ | **enter** | (activityId: string, token: string, onSuccess?: ((data: unknown) =&gt; void) \| undefined, onFailure?: ((data: unknown) =&gt; void) \| undefined) =&gt; void | Associate a live activity ID with a push token so OneSignal can target it. |
311
+ | **exit** | (activityId: string, onSuccess?: ((data: unknown) =&gt; void) \| undefined, onFailure?: ((data: unknown) =&gt; void) \| undefined) =&gt; void | Disassociate a live activity ID. |
312
+ | **setPushToStartToken** | (activityType: string, token: string) =&gt; Promise&lt;void&gt; | Register a `pushToStart` token for the given live activity attributes type. |
313
+ | **removePushToStartToken** | (activityType: string) =&gt; Promise&lt;void&gt; | Remove a previously registered `pushToStart` token for the given attributes type. |
314
+ | **setupDefault** | (options?: <a href="#liveactivitysetupoptions">LiveActivitySetupOptions</a> \| undefined) =&gt; Promise&lt;void&gt; | Set up the OneSignal default live activity, optionally enabling pushToStart/pushToUpdate. |
315
+ | **startDefault** | (activityId: string, attributes: <a href="#record">Record</a>&lt;string, unknown&gt;, content: <a href="#record">Record</a>&lt;string, unknown&gt;) =&gt; Promise&lt;void&gt; | Start a live activity backed by the OneSignal default attributes type. |
316
+
317
+ ### Type Aliases
318
+
319
+ #### LogLevel
320
+
321
+ <code>(typeof <a href="#loglevel">LogLevel</a>)[keyof typeof LogLevel]</code>
322
+
323
+ #### Record
324
+
325
+ Construct a type with a set of properties K of type T
326
+
327
+ <code>{
328
+ [P in K]: T;
329
+ }</code>
330
+
331
+ #### OSNotificationPermission
332
+
333
+ <code>(typeof <a href="#osnotificationpermission">OSNotificationPermission</a>)[keyof typeof OSNotificationPermission]</code>
334
+
335
+ #### NotificationEventName
336
+
337
+ <code>'click' | 'foregroundWillDisplay' | 'permissionChange'</code>
338
+
339
+ #### NotificationEventTypeMap
340
+
341
+ <code>{ click: <a href="#notificationclickevent">NotificationClickEvent</a>; foregroundWillDisplay: NotificationWillDisplayEvent; permissionChange: boolean; }</code>
342
+
343
+ #### InAppMessageEventName
344
+
345
+ <code>'click' | 'willDisplay' | 'didDisplay' | 'willDismiss' | 'didDismiss'</code>
346
+
347
+ #### InAppMessageEventTypeMap
348
+
349
+ <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>
350
+
351
+ #### InAppMessageActionUrlType
352
+
353
+ <code>'browser' | 'webview' | 'replacement'</code>
354
+
355
+ #### LiveActivitySetupOptions
356
+
357
+ The setup options for `OneSignal.LiveActivities.setupDefault`.
358
+
359
+ <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>
360
+
361
+ </docgen-api>
@@ -0,0 +1,126 @@
1
+ buildscript {
2
+ val catalogFile = file("gradle/libs.versions.toml")
3
+
4
+ // Lightweight reader for the [versions] table of libs.versions.toml.
5
+ // Inlined here because buildscript {} is evaluated before the rest of the
6
+ // script body, and Gradle's built-in version catalog APIs aren't available
7
+ // to a Capacitor plugin consumed as a sub-project.
8
+ fun fromCatalog(key: String): String {
9
+ var inVersions = false
10
+ var result: String? = null
11
+ catalogFile.forEachLine { raw ->
12
+ if (result != null) return@forEachLine
13
+ val line = raw.substringBefore("#").trim()
14
+ when {
15
+ line.startsWith("[") && line.endsWith("]") -> inVersions = (line == "[versions]")
16
+ inVersions && "=" in line -> {
17
+ val (rawKey, rawValue) = line.split("=", limit = 2)
18
+ if (rawKey.trim() == key) {
19
+ result = rawValue.trim().trim('"')
20
+ }
21
+ }
22
+ }
23
+ }
24
+ return result ?: error("Version '$key' not found in ${catalogFile.name}")
25
+ }
26
+
27
+ val kotlinVersion: String = if (project.hasProperty("kotlin_version")) {
28
+ rootProject.extra["kotlin_version"] as String
29
+ } else {
30
+ fromCatalog("kotlin")
31
+ }
32
+ val androidGradlePluginVersion: String = fromCatalog("androidGradlePlugin")
33
+
34
+ repositories {
35
+ google()
36
+ mavenCentral()
37
+ }
38
+ dependencies {
39
+ classpath("com.android.tools.build:gradle:$androidGradlePluginVersion")
40
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
41
+ }
42
+ }
43
+
44
+ // Duplicates the buildscript-local reader intentionally: the buildscript block
45
+ // closes over its own scope, so this helper is reused for the module body.
46
+ fun catalogVersion(key: String): String {
47
+ val toml = file("gradle/libs.versions.toml")
48
+ var inVersions = false
49
+ var result: String? = null
50
+ toml.forEachLine { raw ->
51
+ if (result != null) return@forEachLine
52
+ val line = raw.substringBefore("#").trim()
53
+ when {
54
+ line.startsWith("[") && line.endsWith("]") -> inVersions = (line == "[versions]")
55
+ inVersions && "=" in line -> {
56
+ val (rawKey, rawValue) = line.split("=", limit = 2)
57
+ if (rawKey.trim() == key) {
58
+ result = rawValue.trim().trim('"')
59
+ }
60
+ }
61
+ }
62
+ }
63
+ return result ?: error("Version '$key' not found in ${toml.name}")
64
+ }
65
+
66
+ fun propertyOrCatalog(propertyName: String, catalogKey: String): String =
67
+ if (project.hasProperty(propertyName)) {
68
+ rootProject.extra[propertyName] as String
69
+ } else {
70
+ catalogVersion(catalogKey)
71
+ }
72
+
73
+ fun intPropertyOrCatalog(propertyName: String, catalogKey: String): Int =
74
+ if (project.hasProperty(propertyName)) {
75
+ rootProject.extra[propertyName] as Int
76
+ } else {
77
+ catalogVersion(catalogKey).toInt()
78
+ }
79
+
80
+ val junitVersion: String = propertyOrCatalog("junitVersion", "junit")
81
+ val androidxAppCompatVersion: String = propertyOrCatalog("androidxAppCompatVersion", "androidxAppCompat")
82
+
83
+ extra["junitVersion"] = junitVersion
84
+ extra["androidxAppCompatVersion"] = androidxAppCompatVersion
85
+
86
+ apply(plugin = "com.android.library")
87
+ apply(plugin = "kotlin-android")
88
+
89
+ configure<com.android.build.gradle.LibraryExtension> {
90
+ namespace = "com.onesignal.capacitor"
91
+ compileSdk = intPropertyOrCatalog("compileSdkVersion", "compileSdk")
92
+ defaultConfig {
93
+ minSdk = intPropertyOrCatalog("minSdkVersion", "minSdk")
94
+ @Suppress("DEPRECATION")
95
+ targetSdk = intPropertyOrCatalog("targetSdkVersion", "targetSdk")
96
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
97
+ }
98
+ buildTypes {
99
+ getByName("release") {
100
+ isMinifyEnabled = false
101
+ proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
102
+ }
103
+ }
104
+ compileOptions {
105
+ sourceCompatibility = JavaVersion.VERSION_17
106
+ targetCompatibility = JavaVersion.VERSION_17
107
+ }
108
+ }
109
+
110
+ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
111
+ kotlinOptions.jvmTarget = "17"
112
+ }
113
+
114
+ repositories {
115
+ google()
116
+ mavenCentral()
117
+ }
118
+
119
+ dependencies {
120
+ "implementation"(project(":capacitor-android"))
121
+ "implementation"("androidx.appcompat:appcompat:$androidxAppCompatVersion")
122
+ "implementation"("com.onesignal:OneSignal:${catalogVersion("onesignal")}")
123
+ "testImplementation"("junit:junit:$junitVersion")
124
+ "androidTestImplementation"("androidx.test.ext:junit:${catalogVersion("androidxTestJunit")}")
125
+ "androidTestImplementation"("androidx.test.espresso:espresso-core:${catalogVersion("androidxEspresso")}")
126
+ }
@@ -0,0 +1,25 @@
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
+ #
5
+ # compileSdk / minSdk / targetSdk / kotlin / appcompat / junit follow
6
+ # Capacitor 7's required versions, not the OneSignal Android SDK's.
7
+
8
+ [versions]
9
+ androidGradlePlugin = "8.7.3"
10
+ androidxAppCompat = "1.7.0"
11
+ androidxEspresso = "3.6.1"
12
+ androidxTestJunit = "1.2.1"
13
+ compileSdk = "35"
14
+ junit = "4.13.2"
15
+ kotlin = "1.9.25"
16
+ minSdk = "23"
17
+ onesignal = "5.7.7"
18
+ targetSdk = "35"
19
+
20
+ [libraries]
21
+ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidxAppCompat" }
22
+ androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidxEspresso" }
23
+ androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "androidxTestJunit" }
24
+ junit = { module = "junit:junit", version.ref = "junit" }
25
+ onesignal = { module = "com.onesignal:OneSignal", version.ref = "onesignal" }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.onesignal.capacitor">
3
+ </manifest>