Skip to content

Commit a54c870

Browse files
authored
Merge pull request #179 from OneSignal/cd_update
sync with web-shim-codegen v3.0.5
2 parents 48e8f3d + 2d2b0e7 commit a54c870

File tree

5 files changed

+41
-14
lines changed

5 files changed

+41
-14
lines changed

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ build
1818

1919
npm-debug.log*
2020
example
21+
22+
.github
23+
.releaserc.json
24+
25+
.eslintignore
26+
.gitignore

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- 🏠 [Homepage](https://github.com/OneSignal/react-onesignal#readme)
2020
- 🖤 [npm](https://www.npmjs.com/package/react-onesignal)
2121

22-
OneSignal is the world's leader for Mobile Push Notifications, Web Push, and In-App Messaging. It is trusted by 2 million+ businesses to send 9 billion Push Notifications per day.
22+
OneSignal is the world's leader for Mobile Push Notifications, Web Push, and In-App Messaging. It is trusted by 2 million+ developers to send 12 billion Push Notifications per day.
2323

2424
You can find more information on OneSignal [here](https://onesignal.com/).
2525

@@ -83,8 +83,7 @@ OneSignal.init({ appId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }).then(() => {
8383
```
8484

8585
### Init Options
86-
87-
You can pass other [options](https://documentation.onesignal.com/v11.0/docs/web-sdk#initializing-the-sdk) to the `init` function. Use these options to configure personalized prompt options, auto-resubscribe, and more.
86+
You can pass other [options](https://documentation.onesignal.com/docs/web-sdk-reference#init) to the `init` function. Use these options to configure personalized prompt options, auto-resubscribe, and more.
8887

8988
<details>
9089
<summary>Expand to see more options</summary>
@@ -155,7 +154,7 @@ interface IOneSignalOneSignal {
155154

156155
### OneSignal API
157156

158-
See the official [OneSignal WebSDK reference](https://documentation.onesignal.com/v11.0/docs/web-sdk) for information on all available SDK functions.
157+
See the official [OneSignal WebSDK reference](https://documentation.onesignal.com/docs/web-sdk-reference) for information on all available SDK functions.
159158

160159
---
161160

@@ -195,7 +194,9 @@ OneSignal.Notifications.addEventListener('click', (event) => {
195194
});
196195
```
197196

198-
See the [OneSignal WebSDK Reference](https://documentation.onesignal.com/v11.0/docs/web-sdk) for all available event listeners.
197+
198+
199+
See the [OneSignal WebSDK Reference](https://documentation.onesignal.com/docs/web-sdk-reference#addeventlistener-push-notification) for all available event listeners.
199200

200201
## Troubleshooting
201202

index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import OneSignal from './index';
22

3-
const originalDocument = global.document;
4-
const documentSpy = vi.spyOn(global, 'document', 'get');
3+
const originalDocument = window.document;
4+
const documentSpy = vi.spyOn(window, 'document', 'get');
55

66
const APP_ID = '123456';
77

index.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ const init = (options: IInitObject): Promise<void> => {
107107
return Promise.reject(`Document is not defined.`);
108108
}
109109

110+
// Handle both disabled and disable keys for welcome notification
111+
if (options.welcomeNotification?.disabled !== undefined) {
112+
options.welcomeNotification.disable = options.welcomeNotification.disabled;
113+
}
114+
110115
return new Promise<void>((resolve, reject) => {
111116
window.OneSignalDeferred?.push((OneSignal) => {
112117
OneSignal.init(options)
@@ -332,9 +337,15 @@ export interface IInitObject {
332337
welcomeNotification?: {
333338
/**
334339
* Disables sending a welcome notification to new site visitors. If you want to disable welcome notifications, this is the only option you need.
340+
* @deprecated Use 'disable' instead. This will be removed in a future version.
335341
*/
336342
disabled?: boolean;
337343

344+
/**
345+
* Disables sending a welcome notification to new site visitors. If you want to disable welcome notifications, this is the only option you need.
346+
*/
347+
disable?: boolean;
348+
338349
/**
339350
* The welcome notification's message. You can localize this to your own language.
340351
* If left blank or set to blank, the default of 'Thanks for subscribing!' will be used.
@@ -351,7 +362,7 @@ export interface IInitObject {
351362
* By default, clicking the welcome notification does not open any link.
352363
* This is recommended because the user has just visited your site and subscribed.
353364
*/
354-
url: string;
365+
url?: string;
355366
};
356367

357368
/**
@@ -482,7 +493,7 @@ export interface IOneSignalSlidedown {
482493
removeEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
483494
}
484495
export interface IOneSignalDebug {
485-
setLogLevel(logLevel: string): void;
496+
setLogLevel(logLevel: 'trace' | 'debug' | 'info' | 'warn' | 'error'): void;
486497
}
487498
export interface IOneSignalSession {
488499
sendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void>;
@@ -869,9 +880,10 @@ function userRemoveTags(keys: string[]): void {
869880
});
870881

871882
}
872-
function userGetTags(): { [key: string]: string } {
883+
// @ts-expect-error - return non-Promise type despite needing to await OneSignalDeferred
884+
async function userGetTags(): { [key: string]: string } {
873885
let retVal: { [key: string]: string };
874-
window.OneSignalDeferred?.push((OneSignal: IOneSignalOneSignal) => {
886+
await window.OneSignalDeferred?.push((OneSignal: IOneSignalOneSignal) => {
875887
retVal = OneSignal.User.getTags();
876888
});
877889
return retVal;
@@ -897,9 +909,10 @@ function userSetLanguage(language: string): void {
897909
});
898910

899911
}
900-
function userGetLanguage(): string {
912+
// @ts-expect-error - return non-Promise type despite needing to await OneSignalDeferred
913+
async function userGetLanguage(): string {
901914
let retVal: string;
902-
window.OneSignalDeferred?.push((OneSignal: IOneSignalOneSignal) => {
915+
await window.OneSignalDeferred?.push((OneSignal: IOneSignalOneSignal) => {
903916
retVal = OneSignal.User.getLanguage();
904917
});
905918
return retVal;
@@ -952,7 +965,7 @@ function pushSubscriptionRemoveEventListener(event: 'change', listener: (change:
952965
});
953966

954967
}
955-
function debugSetLogLevel(logLevel: string): void {
968+
function debugSetLogLevel(logLevel: 'trace' | 'debug' | 'info' | 'warn' | 'error'): void {
956969

957970
window.OneSignalDeferred?.push((OneSignal: IOneSignalOneSignal) => {
958971
OneSignal.Debug.setLogLevel(logLevel);

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
"vite-plugin-dts": "^4.5.3",
4747
"vitest": "^3.0.9"
4848
},
49+
"files": [
50+
"dist",
51+
"README.md",
52+
"LICENSE",
53+
"CHANGELOG.md",
54+
"MigrationGuide.md"
55+
],
4956
"keywords": [
5057
"onesignal",
5158
"push",

0 commit comments

Comments
 (0)