react-onesignal 2.0.4 → 3.0.0-beta.1

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,19 @@
1
+ name: 🙋‍♂️ Ask a question
2
+ description: Tell us what's on your mind
3
+ title: "[Question]: "
4
+ labels: ["triage"]
5
+ assignees:
6
+ - OneSignal/eng-developer-sdk
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: |
11
+ Having issues integrating this SDK?
12
+ - type: textarea
13
+ id: question
14
+ attributes:
15
+ label: How can we help?
16
+ description: Specific question regarding integrating this SDK.
17
+ placeholder: How do I...?
18
+ validations:
19
+ required: true
@@ -0,0 +1,70 @@
1
+ name: 🪳 Bug report
2
+ description: File a bug report
3
+ title: "[Bug]: "
4
+ labels: ["bug", "triage"]
5
+ assignees:
6
+ - OneSignal/eng-developer-sdk
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: |
11
+ Thanks for taking the time to fill out this bug report!
12
+ - type: textarea
13
+ id: what-happened
14
+ attributes:
15
+ label: What happened?
16
+ description: Provide a thorough description of whats going on.
17
+ placeholder: The latest version of the SDK causes a runtime error.
18
+ validations:
19
+ required: true
20
+ - type: dropdown
21
+ id: browsers
22
+ attributes:
23
+ label: What browsers are you seeing the problem on?
24
+ multiple: true
25
+ options:
26
+ - Firefox
27
+ - Chrome (Chromium)
28
+ - Safari
29
+ - Microsoft Edge
30
+ - Opera
31
+ - Brave
32
+ - Other
33
+ validations:
34
+ required: true
35
+ - type: input
36
+ id: operating-system
37
+ attributes:
38
+ label: What operating system are you running?
39
+ description: Make sure to include the version.
40
+ placeholder: macOS Monterey 12.3.1
41
+ validations:
42
+ required: true
43
+ - type: textarea
44
+ id: reproduction-steps
45
+ attributes:
46
+ label: Steps to reproduce?
47
+ description: Provide as much detail as posible to reproduce the issue.
48
+ placeholder: |
49
+ 1. Install dependencies: vX.Y.Z, etc...
50
+ 2. Run the app
51
+ 3. Click on the notification prompt
52
+ 4. Note that this causes a runtime error and a failed subscription.
53
+ render: Markdown
54
+ validations:
55
+ required: true
56
+ - type: textarea
57
+ id: what-are-expectations
58
+ attributes:
59
+ label: What did you expect to happen?
60
+ description: Also tell us, what did you expect to happen?
61
+ placeholder: I expected the notification prompt to cause a native permission change in the browser.
62
+ validations:
63
+ required: true
64
+ - type: textarea
65
+ id: logs
66
+ attributes:
67
+ label: Relevant log output
68
+ description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
69
+ render: Shell
70
+
@@ -0,0 +1,19 @@
1
+ name: 📣 General feedback
2
+ description: Tell us what's on your mind
3
+ title: "[Feedback]: "
4
+ labels: ["triage"]
5
+ assignees:
6
+ - OneSignal/eng-developer-sdk
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: |
11
+ Thanks for sharing your valuable feedback!
12
+ - type: textarea
13
+ id: feedback
14
+ attributes:
15
+ label: What's on your mind?
16
+ description: Feedback regarding this SDK.
17
+ placeholder: Share your feedback...
18
+ validations:
19
+ required: true
@@ -0,0 +1,34 @@
1
+ # This is an action to close asana tasks that were generated by Github issues
2
+
3
+ name: Zapier web hook
4
+
5
+ # Controls when the workflow will run
6
+ on:
7
+ # Triggers the workflow on push or pull request events but only for the "main" branch
8
+ issues:
9
+ types: [closed]
10
+
11
+ permissions:
12
+ issues: read
13
+
14
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
15
+ jobs:
16
+ # This workflow contains a single job called "build"
17
+ build:
18
+ # The type of runner that the job will run on
19
+ runs-on: ubuntu-latest
20
+
21
+ # Steps represent a sequence of tasks that will be executed as part of the job
22
+ steps:
23
+ # Runs a set of commands using the runners shell
24
+ - name: Call Zapier web hook to close Asana task
25
+ if: ${{ !github.event.issue.pull_request }}
26
+ env:
27
+ ISSUE_TITLE: ${{ github.event.issue.title }}
28
+ run: |
29
+ curl --location --request POST 'https://hooks.zapier.com/hooks/catch/12728683/b7009qc/' \
30
+ --header 'Content-Type: application/json' \
31
+ --header 'Accept: application/json' \
32
+ --data-raw '{
33
+ "task_name" : "$ISSUE_TITLE"
34
+ }'
@@ -0,0 +1,41 @@
1
+ name: Release Drafter
2
+
3
+ on:
4
+ push:
5
+ # branches to consider in the event; optional, defaults to all
6
+ branches:
7
+ - main
8
+ # pull_request event is required only for autolabeler
9
+ pull_request:
10
+ # Only following types are handled by the action, but one can default to all as well
11
+ types: [opened, reopened, synchronize]
12
+ # pull_request_target event is required for autolabeler to support PRs from forks
13
+ # pull_request_target:
14
+ # types: [opened, reopened, synchronize]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ update_release_draft:
21
+ permissions:
22
+ # write permission is required to create a github release
23
+ contents: write
24
+ # write permission is required for autolabeler
25
+ # otherwise, read permission is required at least
26
+ pull-requests: write
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ # (Optional) GitHub Enterprise requires GHE_HOST variable set
30
+ #- name: Set GHE_HOST
31
+ # run: |
32
+ # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
33
+
34
+ # Drafts your next Release notes as Pull Requests are merged into "master"
35
+ - uses: release-drafter/release-drafter@v5
36
+ # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
37
+ # with:
38
+ # config-name: my-config.yml
39
+ # disable-autolabeler: true
40
+ env:
41
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,27 @@
1
+ name-template: $RESOLVED_VERSION
2
+ tag-template: $RESOLVED_VERSION
3
+ categories:
4
+ - title: 🚀 Features
5
+ label: Enhancement / Feature
6
+ - title: 🐛 Bug Fixes
7
+ label: Bug
8
+ - title: 🧰 Improvements
9
+ label: Improvement
10
+ - title: down arrow Dependency Updates
11
+ label: Dependencies
12
+ change-template: '- $TITLE (#$NUMBER)'
13
+ version-resolver:
14
+ major:
15
+ labels:
16
+ - 'major'
17
+ minor:
18
+ labels:
19
+ - 'minor'
20
+ patch:
21
+ labels:
22
+ - 'patch'
23
+ default: patch
24
+ template: |
25
+ ## Other Changes
26
+
27
+ $CHANGES
package/MigrationGuide.md CHANGED
@@ -2,77 +2,333 @@
2
2
  # Migration Guide
3
3
  Review the updated documentation in the [README](https://github.com/OneSignal/react-onesignal/blob/master/README.md).
4
4
 
5
- ## Version 2
6
- Version 2.0 includes breaking changes. Make sure to follow this migration guide carefully, review the updated documentation, and test your application thoroughly.
5
+ > Migrating from version 1 to 2 (see [v2 migration guide](#version-2))
7
6
 
8
- ## Key Changes
9
- - Update your OneSignal initialization function (see below)
10
- - Remove the initialization hook (now handled for you automagically)
11
- - Event listeners are now set up using the `on` function
12
- - New functions supporting newer OneSignal features
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.
13
10
 
14
- ### OneSignal Initialization
15
- 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:
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.
16
12
 
17
- ```js
18
- import OneSignal from 'react-onesignal';
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.
19
27
 
20
- OneSignal.init({ appId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' });
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
+ ]
21
42
  ```
22
43
 
23
- 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).
24
-
25
- ### Event Listeners
26
- Event listeners can now be added directly via the `on` function. This function takes an event string and a callback.
27
-
28
- ### New Features
29
- We have added new functions to support the latest OneSignal functions and features.
30
-
31
- ### Typings
32
- Typings are included in the package automatically. See below for a full list of the functions included in this package:
33
- ```ts
34
- interface OneSignal {
35
- init(options?: any): Promise<void>
36
- on(event: string, listener: Function): void
37
- off(event: string, listener: Function): void
38
- once(event: string, listener: Function): void
39
- isPushNotificationsEnabled(callback?: Action<boolean>): Promise<boolean>
40
- showHttpPrompt(options?: AutoPromptOptions): void
41
- registerForPushNotifications(options?: RegisterOptions): Promise<void>
42
- setDefaultNotificationUrl(url: string): void
43
- setDefaultTitle(title: string): void
44
- getTags(callback?: Action<any>): void
45
- sendTag(key: string, value: any, callback?: Action<Object>): Promise<Object | null>
46
- sendTags(tags: TagsObject<any>, callback?: Action<Object>): Promise<Object | null>
47
- deleteTag(tag: string): Promise<Array<string>>
48
- deleteTags(tags: Array<string>, callback?: Action<Array<string>>): Promise<Array<string>>
49
- addListenerForNotificationOpened(callback?: Action<Notification>): void
50
- setSubscription(newSubscription: boolean): Promise<void>
51
- showHttpPermissionRequest(options?: AutoPromptOptions): Promise<any>
52
- showNativePrompt(): Promise<void>
53
- showSlidedownPrompt(options?: AutoPromptOptions): Promise<void>
54
- showCategorySlidedown(options?: AutoPromptOptions): Promise<void>
55
- showSmsSlidedown(options?: AutoPromptOptions): Promise<void>
56
- showEmailSlidedown(options?: AutoPromptOptions): Promise<void>
57
- showSmsAndEmailSlidedown(options?: AutoPromptOptions): Promise<void>
58
- getNotificationPermission(onComplete?: Function): Promise<NotificationPermission>
59
- getUserId(callback?: Action<string | undefined | null>): Promise<string | undefined | null>
60
- getSubscription(callback?: Action<boolean>): Promise<boolean>
61
- setEmail(email: string, options?: SetEmailOptions): Promise<string|null>
62
- setSMSNumber(smsNumber: string, options?: SetSMSOptions): Promise<string | null>
63
- logoutEmail(): void
64
- logoutSMS(): void
65
- setExternalUserId(externalUserId: string | undefined | null, authHash?: string): Promise<void>
66
- removeExternalUserId(): Promise<void>
67
- getExternalUserId(): Promise<string | undefined | null>
68
- provideUserConsent(consent: boolean): Promise<void>
69
- getEmailId(callback?: Action<string | undefined>): Promise<string | null | undefined>
70
- getSMSId(callback?: Action<string | undefined>): Promise<string | null | undefined>
71
- sendOutcome(outcomeName: string, outcomeWeight?: number | undefined): Promise<void>
44
+ ```js
45
+ // WebSDK-specific example
46
+ {
47
+ external_id: "1234",
48
+ my_alias: "5678"
72
49
  }
73
50
  ```
74
51
 
75
- ## Summary
76
- Consider the above changes when migrating to version 2 and make sure to thoroughly test your application.
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
+ | Sync/Async | Function Name | Description | Argument List |
115
+ | ---------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
116
+ | `async` | `setDefaultUrl` | Sets the default URL for notifications. | `url` (string) |
117
+ | `async` | `setDefaultTitle` | Sets the default title for notifications. | `title` (string) |
118
+ | `sync` | `isPushSupported` | Returns true if the current browser supports web push. | |
119
+ | `async` | `getPermissionStatus` | Returns the browser's current notification permission. | `onComplete` (Action<NotificationPermission>) |
120
+ | `async` | `requestPermission` | Requests push notifications permission via the native browser prompt. | |
121
+ | `sync` | `addEventListener` | Adds an event listener for the following events:<br><br>- `click`<br>- `willDisplay`<br>- `dismiss`<br>- `permissionPromptDisplay`<br>- `permissionChange`*<br> * argument type: bool | - `<event>` (string)<br>- `(arg: <type>) => {}` (callback) |
122
+ | `sync` | `removeEventListener` | Removes the event listener. | `() => {}` (the event listener you want to remove) |
123
+
124
+
125
+
126
+ ### Slidedown Namespace
127
+
128
+ Example:
129
+ ```js
130
+ await OneSignal.Slidedown.promptPush();
131
+ ```
132
+
133
+ | Sync/Async | Function Name | Description | Argument List |
134
+ | ---------- | ---------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------- |
135
+ | `async` | `promptPush` | Displays the notification permission prompt. | `options` (AutoPromptOptions) |
136
+ | `async` | `promptPushCategories` | Displays the notification permission prompt for notification categories. | `options` (AutoPromptOptions) |
137
+ | `async` | `promptSms` | Displays the SMS subscription prompt. | `options` (AutoPromptOptions) |
138
+ | `async` | `promptEmail` | Displays the email subscription prompt. | `options` (AutoPromptOptions) |
139
+ | `async` | `promptSmsAndEmail` | Displays the SMS and email subscription prompts. | `options` (AutoPromptOptions) |
140
+ | `sync` | `addEventListener` | Adds an event listener for the `slidedownShown` event. | - `event` ("slidedownShown"), <br>- `listener` ((wasShown: boolean) => void) |
141
+ | `sync` | `removeEventListener` | Removes an event listener for the `slidedownShown` event. | - `event` ("slidedownShown")<br>- `listener` ((wasShown: boolean) => void) |
142
+
143
+
144
+
145
+ ### Push Subscription Namespace
146
+
147
+ Example:
148
+ ```js
149
+ OneSignal.User.PushSubscription.optIn();
150
+ ```
151
+
152
+ | Sync/Async | Property/Function | Description | Argument List |
153
+ | ---------- | ----------------------- | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
154
+ | | `id` | Gets the current user's ID. | |
155
+ | | `token` | Gets the current user's push notification token. | |
156
+ | | `optedIn` | Gets a boolean value indicating whether the current user is subscribed to push notifications. | |
157
+ | `async` | `optIn()` | Subscribes the current user to push notifications. | |
158
+ | `async` | `optOut()` | Unsubscribes the current user from push notifications. | |
159
+ | `sync` | `addEventListener()` | Adds an event listener for the `subscriptionChange` event. | - `event` ("subscriptionChange")<br>- `listener` ((change: SubscriptionChangeEvent) => void) |
160
+ | `sync` | `removeEventListener()` | Removes an event listener for the `subscriptionChange` event. | - `event` ("subscriptionChange")<br>- `listener` ((change: SubscriptionChangeEvent) => void) |
161
+
162
+ ### Debug Namespace
163
+
164
+ Example:
165
+ ```js
166
+ OneSignal.Debug.setLogLevel(“trace”);
167
+ ```
168
+
169
+ | Function Name | Description | Argument List |
170
+ | --------------- | ---------------------------------------------- | ------------------------------------ |
171
+ | `setLogLevel` | Turns on logging with the given log level. | `setLogLevel: string`<br>- `"trace"`<br>- `"debug"`<br>- `"info"`<br>- `"warn"`<br>- `"error"` |
172
+
173
+ # Limitations
174
+
175
+ ## January 2023
176
+ ### Version 16 (alpha)
177
+ It is recommended this version is used **only** in development and staging envrionments.
178
+ * Switching between users via `login()` and `logout()` is unsafe. **Please stick to single user testing.**
179
+ * Any User namespace calls must be invoked **after** initialization (async). Example: `OneSignal.User.addTag("tag", "2");`
180
+ * Aliases will be available in a future release,
181
+ * HTTP environments are not supported.
182
+ * AMP environments are not supported.
183
+ * Identity verification is not functional.
184
+ * Outcomes are not functional.
185
+
186
+
187
+ # Glossary
188
+
189
+ **OneSignal user**
190
+
191
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
192
+
193
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A user of the OneSignal service.
194
+
195
+ **user**
196
+
197
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
198
+
199
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;An end-user of an application using the OneSignal service. They may or may not have a subscription.
200
+
201
+ **user ID**
202
+
203
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
204
+
205
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A OneSignal-provisioned unique identifier for Users (User.onesignal_id).
206
+
207
+
208
+ **user external ID**
209
+
210
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
211
+
212
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A customer-provisioned unique identifier for Users (User.external_id).
213
+
214
+
215
+ **user alias**
216
+
217
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
218
+
219
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A customer provisioned key-value pair used to uniquely identify a User.
220
+
221
+
222
+ **subscription**
223
+
224
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
225
+
226
+ &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.
227
+
228
+
229
+ **subscription ID**
230
+
231
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
232
+
233
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A OneSignal-provisioned unique identifier for a single subscription.
234
+
235
+
236
+ **notification**
237
+
238
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
239
+
240
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A unidirectional outbound communication message from an App to one or more Users via their Subscriptions.
241
+
242
+
243
+ **notification ID**
244
+
245
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
246
+
247
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A OneSignal-provisioned unique identifier for Notifications (Notification.id).
248
+
249
+
250
+ **notification external ID**
251
+
252
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*(noun) lowercase*
253
+
254
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A customer-provisioned unique identifier for Notifications (Notification.external_id).
255
+
256
+
257
+ ## Version 2
258
+ <details>
259
+ <summary>Click to expand</summary>
260
+
261
+ Version 2.0 includes breaking changes. Make sure to follow this migration guide carefully, review the updated documentation, and test your application thoroughly.
262
+
263
+ ## Key Changes
264
+ - Update your OneSignal initialization function (see below)
265
+ - Remove the initialization hook (now handled for you automagically)
266
+ - Event listeners are now set up using the `on` function
267
+ - New functions supporting newer OneSignal features
268
+
269
+ ### OneSignal Initialization
270
+ 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:
271
+
272
+ ```js
273
+ import OneSignal from 'react-onesignal';
274
+
275
+ OneSignal.init({ appId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' });
276
+ ```
277
+
278
+ 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).
279
+
280
+ ### Event Listeners
281
+ Event listeners can now be added directly via the `on` function. This function takes an event string and a callback.
282
+
283
+ ### New Features
284
+ We have added new functions to support the latest OneSignal functions and features.
285
+
286
+ ### Typings
287
+ Typings are included in the package automatically. See below for a full list of the functions included in this package:
288
+ ```ts
289
+ interface OneSignal {
290
+ init(options?: any): Promise<void>
291
+ on(event: string, listener: Function): void
292
+ off(event: string, listener: Function): void
293
+ once(event: string, listener: Function): void
294
+ isPushNotificationsEnabled(callback?: Action<boolean>): Promise<boolean>
295
+ showHttpPrompt(options?: AutoPromptOptions): void
296
+ registerForPushNotifications(options?: RegisterOptions): Promise<void>
297
+ setDefaultNotificationUrl(url: string): void
298
+ setDefaultTitle(title: string): void
299
+ getTags(callback?: Action<any>): void
300
+ sendTag(key: string, value: any, callback?: Action<Object>): Promise<Object | null>
301
+ sendTags(tags: TagsObject<any>, callback?: Action<Object>): Promise<Object | null>
302
+ deleteTag(tag: string): Promise<Array<string>>
303
+ deleteTags(tags: Array<string>, callback?: Action<Array<string>>): Promise<Array<string>>
304
+ addListenerForNotificationOpened(callback?: Action<Notification>): void
305
+ setSubscription(newSubscription: boolean): Promise<void>
306
+ showHttpPermissionRequest(options?: AutoPromptOptions): Promise<any>
307
+ showNativePrompt(): Promise<void>
308
+ showSlidedownPrompt(options?: AutoPromptOptions): Promise<void>
309
+ showCategorySlidedown(options?: AutoPromptOptions): Promise<void>
310
+ showSmsSlidedown(options?: AutoPromptOptions): Promise<void>
311
+ showEmailSlidedown(options?: AutoPromptOptions): Promise<void>
312
+ showSmsAndEmailSlidedown(options?: AutoPromptOptions): Promise<void>
313
+ getNotificationPermission(onComplete?: Function): Promise<NotificationPermission>
314
+ getUserId(callback?: Action<string | undefined | null>): Promise<string | undefined | null>
315
+ getSubscription(callback?: Action<boolean>): Promise<boolean>
316
+ setEmail(email: string, options?: SetEmailOptions): Promise<string|null>
317
+ setSMSNumber(smsNumber: string, options?: SetSMSOptions): Promise<string | null>
318
+ logoutEmail(): void
319
+ logoutSMS(): void
320
+ setExternalUserId(externalUserId: string | undefined | null, authHash?: string): Promise<void>
321
+ removeExternalUserId(): Promise<void>
322
+ getExternalUserId(): Promise<string | undefined | null>
323
+ provideUserConsent(consent: boolean): Promise<void>
324
+ getEmailId(callback?: Action<string | undefined>): Promise<string | null | undefined>
325
+ getSMSId(callback?: Action<string | undefined>): Promise<string | null | undefined>
326
+ sendOutcome(outcomeName: string, outcomeWeight?: number | undefined): Promise<void>
327
+ }
328
+ ```
329
+
330
+ ## Summary
331
+ Consider the above changes when migrating to version 2 and make sure to thoroughly test your application.
77
332
 
78
- Enjoy!
333
+ Enjoy!
334
+ </details>