react-onesignal 3.4.1 → 3.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-onesignal",
3
- "version": "3.4.1",
3
+ "version": "3.4.3",
4
4
  "description": "React OneSignal Module: Make it easy to integrate OneSignal with your React App!",
5
5
  "contributors": [
6
6
  {
@@ -53,11 +53,7 @@
53
53
  "vitest": "^3.0.9"
54
54
  },
55
55
  "files": [
56
- "dist",
57
- "README.md",
58
- "LICENSE",
59
- "CHANGELOG.md",
60
- "MigrationGuide.md"
56
+ "dist"
61
57
  ],
62
58
  "keywords": [
63
59
  "onesignal",
package/CHANGELOG.md DELETED
@@ -1,48 +0,0 @@
1
- # Changelog
2
-
3
- ## [3.4.1](https://github.com/OneSignal/react-onesignal/compare/3.4.0...3.4.1) (2025-12-26)
4
-
5
- ## [3.4.0](https://github.com/OneSignal/react-onesignal/compare/3.3.0...3.4.0) (2025-09-19)
6
-
7
- ### Features
8
-
9
- * add new custom events `trackEvent` method ([40deef9](https://github.com/OneSignal/react-onesignal/commit/40deef97f9a52440f23457ecd0509e5821151820))
10
-
11
- ## [3.3.0](https://github.com/OneSignal/react-onesignal/compare/3.2.3...3.3.0) (2025-09-11)
12
-
13
- ### Features
14
-
15
- * sync with web-shim-codegen v3.0.5 ([2f24a45](https://github.com/OneSignal/react-onesignal/commit/2f24a453d0183f1bb7474e25edf67882b426824d))
16
-
17
- ## [3.2.3](https://github.com/OneSignal/react-onesignal/compare/3.2.2...3.2.3) (2025-06-06)
18
-
19
- ### Bug Fixes
20
-
21
- * sync with web-shim-codegen v3.0.5 ([2d2b0e7](https://github.com/OneSignal/react-onesignal/commit/2d2b0e718a6dd51efe142fd1f416029ce113fd42))
22
-
23
- ## [3.2.2](https://github.com/OneSignal/react-onesignal/compare/3.2.1...3.2.2) (2025-03-28)
24
-
25
- ### Bug Fixes
26
-
27
- * add promise reject for init call ([daadfa8](https://github.com/OneSignal/react-onesignal/commit/daadfa8de3ba98a2b9bd81a497187c4ef07cbc30))
28
- * add promise reject for init call ([f951175](https://github.com/OneSignal/react-onesignal/commit/f9511751b930cc65ec78e355f07056c54ac997be))
29
-
30
- ## [3.2.1](https://github.com/OneSignal/react-onesignal/compare/3.2.0...3.2.1) (2025-03-27)
31
-
32
- ### Bug Fixes
33
-
34
- * lower node engines range ([216c428](https://github.com/OneSignal/react-onesignal/commit/216c4280ecf1aea2722676e5f59f5797b75abbed))
35
-
36
- ## [3.2.0](https://github.com/OneSignal/react-onesignal/compare/3.1.1...3.2.0) (2025-03-24)
37
-
38
- ### Features
39
-
40
- * sync with web-shim-codegen v3.0.2 ([1a23688](https://github.com/OneSignal/react-onesignal/commit/1a23688ba8cb42533ad561ef460eaacf2c9be6d9))
41
-
42
- ## [3.1.1](https://github.com/OneSignal/react-onesignal/compare/3.1.0...3.1.1) (2025-03-14)
43
-
44
- ## [3.1.0](https://github.com/OneSignal/react-onesignal/compare/3.0.1...3.1.0) (2025-03-14)
45
-
46
- ### Features
47
-
48
- * sync with web-shim-codegen v3.0.1 ([93627ba](https://github.com/OneSignal/react-onesignal/commit/93627ba19f6aac555b68ef726b7d6ae9c4aa2a31)), closes [#143](https://github.com/OneSignal/react-onesignal/issues/143)
package/MigrationGuide.md DELETED
@@ -1,327 +0,0 @@
1
-
2
- # Migration Guide
3
- Review the updated documentation in the [README](https://github.com/OneSignal/react-onesignal/blob/master/README.md).
4
-
5
- > Migrating from version 1 to 2 (see [v2 migration guide](#version-2))
6
-
7
- ## Version 3
8
- ### Intro
9
- In this release, we are making a significant shift from a device-centered model to a user-centered model. This means that instead of identifying devices, we now focus on identifying individual users. This update is part of a larger effort to shift towards a user-oriented omni-channel messaging system.
10
-
11
- To facilitate this change, the externalId approach for identifying users is being replaced by the login and logout methods. In addition, the SDK now makes use of namespaces such as User, Notifications, and Slidedown to better separate code.
12
-
13
- This guide will walk you through these and other important changes in the version 16 update.
14
-
15
- ### Overview
16
- Under the new model, the concept of a "player" is being updated to include three new concepts: users, subscriptions, and aliases.
17
-
18
- ### Users
19
- Users own subscriptions and are identified by aliases which are used to point to users using different alias schemes.
20
-
21
- ### Subscriptions
22
-
23
- Subscriptions refer to the way in which a user can receive various communication methods offered by OneSignal, including push notifications, SMS, and email.
24
-
25
- ### Aliases
26
- Aliases are identifiers that point to users and are made up of an alias label and id. Users can have multiple aliases. Consider the need to identify a user with your own application's unique identifier as well as identifiers from other integrated applications.
27
-
28
- The SDK will use `external_id` as the default alias label for the public `OneSignal.login("1234")` method.
29
-
30
- **Alias Example:**
31
- ```
32
- "aliases": [
33
- {
34
- "label": "external_id",
35
- "id": "1234"
36
- },
37
- {
38
- "label": "my_alias",
39
- "id": "5678"
40
- }
41
- ]
42
- ```
43
-
44
- ```js
45
- // WebSDK-specific example
46
- {
47
- external_id: "1234",
48
- my_alias: "5678"
49
- }
50
- ```
51
-
52
- # Guide
53
- ## 1. Setup Changes
54
- ### Service Worker File
55
-
56
- From:
57
- ```js
58
- importScripts("https://onesignal.com/sdks/OneSignalSDKWorker.js");
59
- ```
60
-
61
- To:
62
- ```js
63
- importScripts("https://onesignal.com/sdks/web/v16/OneSignalSDK.sw.js");
64
- ```
65
-
66
- ## 2. External User ID
67
- Update any usages of `OneSignal.setExternalId` to `OneSignal.login` or `OneSignal.logout`
68
- From:
69
- ```js
70
- OneSignal.setExternalId("myId");
71
- ```
72
-
73
- To:
74
- ```js
75
- OneSignal.login("myId");
76
- ```
77
-
78
- Use `OneSignal.logout();` instead anywhere you have `OneSignal.setExternalId("");` or are setting it to `null`.
79
-
80
- ## 3. API Changes
81
- Update your code to use the new API. The following namespaces are on the `OneSignal` object.
82
-
83
- ### User Namespace
84
-
85
- Example:
86
- ```js
87
- OneSignal.User.addAlias("my_alias", "1234");
88
- ```
89
-
90
- All user functions are synchronous.
91
-
92
- | Function Name | Description | Argument List |
93
- | --------------- | ---------------------------------------------- | ------------------------------------ |
94
- | `addAlias` | Adds a new alias for the current user. | `label: string, id: string` |
95
- | `addAliases` | Adds multiple aliases for the current user. | `aliases: { [key: string]: string }` |
96
- | `removeAlias` | Removes an alias for the current user. | `label: string` |
97
- | `removeAliases` | Removes multiple aliases for the current user. | `labels: string[]` |
98
- | `addEmail` | Adds an email address for the current user. | `email: string` |
99
- | `removeEmail` | Removes an email address for the current user. | `email: string` |
100
- | `addSms` | Adds an SMS number for the current user. | `smsNumber: string` |
101
- | `removeSms` | Removes an SMS number for the current user. | `smsNumber: string` |
102
- | `addTag` | Adds a tag for the current user. | `key: string, value: string` |
103
- | `addTags` | Adds multiple tags for the current user. | `tags: { [key: string]: string }` |
104
- | `removeTag` | Removes a tag for the current user. | `key: string` |
105
- | `removeTags` | Removes multiple tags for the current user. | `keys: string[]` |
106
-
107
- ### Notifications Namespace
108
-
109
- Example:
110
- ```js
111
- await OneSignal.Notifications.requestPermission();
112
- ```
113
-
114
-
115
- | Sync/Async | Property/Function | Description | Argument List |
116
- | ---------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
117
- | `async` | `setDefaultUrl()` | Sets the default URL for notifications. | `url` (string) |
118
- | `async` | `setDefaultTitle()` | Sets the default title for notifications. | `title` (string) |
119
- | `sync` | `isPushSupported()` | Returns true if the current browser supports web push. | |
120
- | `async` | `requestPermission()` | Requests push notifications permission via the native browser prompt. | |
121
- | | `permission` | Returns true if your site has permission to display notifications. | |
122
- | | `permissionNative` | Returns browser's native notification permission status; `"default"`(end-user has not accept or decided yet), `"granted"`, or `"denied"`. | |
123
- | `sync` | `addEventListener()` | Adds an event listener for the following events:<br><br>- `click`<br>- `foregroundWillDisplay`<br>- `dismiss`<br>- `permissionPromptDisplay`<br>- `permissionChange`*<br> * argument type: bool | - `<event>` (string)<br>- `(arg: <type>) => {}` (callback) |
124
- | `sync` | `removeEventListener()` | Removes the event listener. | `() => {}` (the event listener you want to remove) |
125
-
126
-
127
-
128
- ### Slidedown Namespace
129
-
130
- Example:
131
- ```js
132
- await OneSignal.Slidedown.promptPush();
133
- ```
134
-
135
- | Sync/Async | Function Name | Description | Argument List |
136
- | ---------- | ---------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------- |
137
- | `async` | `promptPush` | Displays the notification permission prompt. | `options` (AutoPromptOptions) |
138
- | `async` | `promptPushCategories` | Displays the notification permission prompt for notification categories. | `options` (AutoPromptOptions) |
139
- | `async` | `promptSms` | Displays the SMS subscription prompt. | `options` (AutoPromptOptions) |
140
- | `async` | `promptEmail` | Displays the email subscription prompt. | `options` (AutoPromptOptions) |
141
- | `async` | `promptSmsAndEmail` | Displays the SMS and email subscription prompts. | `options` (AutoPromptOptions) |
142
- | `sync` | `addEventListener` | Adds an event listener for the `slidedownShown` event. | - `event` ("slidedownShown"), <br>- `listener` ((wasShown: boolean) => void) |
143
- | `sync` | `removeEventListener` | Removes an event listener for the `slidedownShown` event. | - `event` ("slidedownShown")<br>- `listener` ((wasShown: boolean) => void) |
144
-
145
-
146
-
147
- ### Push Subscription Namespace
148
-
149
- Example:
150
- ```js
151
- OneSignal.User.PushSubscription.optIn();
152
- ```
153
-
154
- | Sync/Async | Property/Function | Description | Argument List |
155
- | ---------- | ----------------------- | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
156
- | | `id` | Gets the current user's ID. | |
157
- | | `token` | Gets the current user's push notification token. | |
158
- | | `optedIn` | Gets a boolean value indicating whether the current user is subscribed to push notifications. | |
159
- | `async` | `optIn()` | Subscribes the current user to push notifications. | |
160
- | `async` | `optOut()` | Unsubscribes the current user from push notifications. | |
161
- | `sync` | `addEventListener()` | Adds an event listener for the `change` event. | - `event` ("change")<br>- `listener` ((change: SubscriptionChangeEvent) => void) |
162
- | `sync` | `removeEventListener()` | Removes an event listener for the `change` event. | - `event` ("change")<br>- `listener` ((change: SubscriptionChangeEvent) => void) |
163
-
164
- ### Debug Namespace
165
-
166
- Example:
167
- ```js
168
- OneSignal.Debug.setLogLevel(“trace”);
169
- ```
170
-
171
- | Function Name | Description | Argument List |
172
- | --------------- | ---------------------------------------------- | ------------------------------------ |
173
- | `setLogLevel` | Turns on logging with the given log level. | `setLogLevel: string`<br>- `"trace"`<br>- `"debug"`<br>- `"info"`<br>- `"warn"`<br>- `"error"` |
174
-
175
- # Limitations
176
- * HTTP environments are no longer supported.
177
- * AMP environments are not supported.
178
- * Identity verification not available yet, coming soon.
179
-
180
- # Glossary
181
-
182
- **OneSignal user**
183
-
184
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
185
-
186
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A user of the OneSignal service.
187
-
188
- **user**
189
-
190
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
191
-
192
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;An end-user of an application using the OneSignal service. They may or may not have a subscription.
193
-
194
- **user ID**
195
-
196
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
197
-
198
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A OneSignal-provisioned unique identifier for Users (User.onesignal_id).
199
-
200
-
201
- **user external ID**
202
-
203
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
204
-
205
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A customer-provisioned unique identifier for Users (User.external_id).
206
-
207
-
208
- **user alias**
209
-
210
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
211
-
212
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A customer provisioned key-value pair used to uniquely identify a User.
213
-
214
-
215
- **subscription**
216
-
217
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
218
-
219
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;An established communication channel between an App and its User, such as a push-subscribed device, email address, or SMS-subscribed phone number.
220
-
221
-
222
- **subscription ID**
223
-
224
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
225
-
226
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A OneSignal-provisioned unique identifier for a single subscription.
227
-
228
-
229
- **notification**
230
-
231
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
232
-
233
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A unidirectional outbound communication message from an App to one or more Users via their Subscriptions.
234
-
235
-
236
- **notification ID**
237
-
238
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
239
-
240
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A OneSignal-provisioned unique identifier for Notifications (Notification.id).
241
-
242
-
243
- **notification external ID**
244
-
245
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
246
-
247
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A customer-provisioned unique identifier for Notifications (Notification.external_id).
248
-
249
-
250
- ## Version 2
251
- <details>
252
- <summary>Click to expand</summary>
253
-
254
- Version 2.0 includes breaking changes. Make sure to follow this migration guide carefully, review the updated documentation, and test your application thoroughly.
255
-
256
- ## Key Changes
257
- - Update your OneSignal initialization function (see below)
258
- - Remove the initialization hook (now handled for you automagically)
259
- - Event listeners are now set up using the `on` function
260
- - New functions supporting newer OneSignal features
261
-
262
- ### OneSignal Initialization
263
- The initialization function has been changed to match 1:1 with the underlying OneSignal WebSDK. The function has been renamed `init`. The `appId` is now set via the single config options argument passed to the `init` function:
264
-
265
- ```js
266
- import OneSignal from 'react-onesignal';
267
-
268
- OneSignal.init({ appId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' });
269
- ```
270
-
271
- Furthermore, there is no longer a need to wrap the initialization in the `useOneSignalSetup` hook. The order of functions relative to the OneSignal initialization no longer matters (although we still recommend initializing OneSignal in a top-level component).
272
-
273
- ### Event Listeners
274
- Event listeners can now be added directly via the `on` function. This function takes an event string and a callback.
275
-
276
- ### New Features
277
- We have added new functions to support the latest OneSignal functions and features.
278
-
279
- ### Typings
280
- Typings are included in the package automatically. See below for a full list of the functions included in this package:
281
- ```ts
282
- interface OneSignal {
283
- init(options?: any): Promise<void>
284
- on(event: string, listener: Function): void
285
- off(event: string, listener: Function): void
286
- once(event: string, listener: Function): void
287
- isPushNotificationsEnabled(callback?: Action<boolean>): Promise<boolean>
288
- showHttpPrompt(options?: AutoPromptOptions): void
289
- registerForPushNotifications(options?: RegisterOptions): Promise<void>
290
- setDefaultNotificationUrl(url: string): void
291
- setDefaultTitle(title: string): void
292
- getTags(callback?: Action<any>): void
293
- sendTag(key: string, value: any, callback?: Action<Object>): Promise<Object | null>
294
- sendTags(tags: TagsObject<any>, callback?: Action<Object>): Promise<Object | null>
295
- deleteTag(tag: string): Promise<Array<string>>
296
- deleteTags(tags: Array<string>, callback?: Action<Array<string>>): Promise<Array<string>>
297
- addListenerForNotificationOpened(callback?: Action<Notification>): void
298
- setSubscription(newSubscription: boolean): Promise<void>
299
- showHttpPermissionRequest(options?: AutoPromptOptions): Promise<any>
300
- showNativePrompt(): Promise<void>
301
- showSlidedownPrompt(options?: AutoPromptOptions): Promise<void>
302
- showCategorySlidedown(options?: AutoPromptOptions): Promise<void>
303
- showSmsSlidedown(options?: AutoPromptOptions): Promise<void>
304
- showEmailSlidedown(options?: AutoPromptOptions): Promise<void>
305
- showSmsAndEmailSlidedown(options?: AutoPromptOptions): Promise<void>
306
- getNotificationPermission(onComplete?: Function): Promise<NotificationPermission>
307
- getUserId(callback?: Action<string | undefined | null>): Promise<string | undefined | null>
308
- getSubscription(callback?: Action<boolean>): Promise<boolean>
309
- setEmail(email: string, options?: SetEmailOptions): Promise<string|null>
310
- setSMSNumber(smsNumber: string, options?: SetSMSOptions): Promise<string | null>
311
- logoutEmail(): void
312
- logoutSMS(): void
313
- setExternalUserId(externalUserId: string | undefined | null, authHash?: string): Promise<void>
314
- removeExternalUserId(): Promise<void>
315
- getExternalUserId(): Promise<string | undefined | null>
316
- provideUserConsent(consent: boolean): Promise<void>
317
- getEmailId(callback?: Action<string | undefined>): Promise<string | null | undefined>
318
- getSMSId(callback?: Action<string | undefined>): Promise<string | null | undefined>
319
- sendOutcome(outcomeName: string, outcomeWeight?: number | undefined): Promise<void>
320
- }
321
- ```
322
-
323
- ## Summary
324
- Consider the above changes when migrating to version 2 and make sure to thoroughly test your application.
325
-
326
- Enjoy!
327
- </details>