Skip to content

Commit 79cb865

Browse files
chore(release): 3.1.1
## [3.1.1](3.1.0...3.1.1) (2025-03-14) [skip ci]
1 parent c8fb318 commit 79cb865

File tree

7 files changed

+1440
-1
lines changed

7 files changed

+1440
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
## [3.1.1](https://github.com/OneSignal/react-onesignal/compare/3.1.0...3.1.1) (2025-03-14)
4+
35
## [3.1.0](https://github.com/OneSignal/react-onesignal/compare/3.0.1...3.1.0) (2025-03-14)
46

57
### Features

dist/index.d.ts

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
declare global {
2+
interface Window {
3+
OneSignalDeferred?: OneSignalDeferredLoadedCallback[];
4+
OneSignal?: IOneSignalOneSignal;
5+
safari?: {
6+
pushNotification: any;
7+
};
8+
}
9+
}
10+
interface AutoPromptOptions {
11+
force?: boolean;
12+
forceSlidedownOverNative?: boolean;
13+
slidedownPromptOptions?: IOneSignalAutoPromptOptions;
14+
}
15+
interface IOneSignalAutoPromptOptions {
16+
force?: boolean;
17+
forceSlidedownOverNative?: boolean;
18+
isInUpdateMode?: boolean;
19+
categoryOptions?: IOneSignalCategories;
20+
}
21+
interface IOneSignalCategories {
22+
positiveUpdateButton: string;
23+
negativeUpdateButton: string;
24+
savingButtonText: string;
25+
errorButtonText: string;
26+
updateMessage: string;
27+
tags: IOneSignalTagCategory[];
28+
}
29+
interface IOneSignalTagCategory {
30+
tag: string;
31+
label: string;
32+
checked?: boolean;
33+
}
34+
declare type PushSubscriptionNamespaceProperties = {
35+
id: string | null | undefined;
36+
token: string | null | undefined;
37+
optedIn: boolean;
38+
};
39+
declare type SubscriptionChangeEvent = {
40+
previous: PushSubscriptionNamespaceProperties;
41+
current: PushSubscriptionNamespaceProperties;
42+
};
43+
declare type NotificationEventName = 'click' | 'foregroundWillDisplay' | 'dismiss' | 'permissionChange' | 'permissionPromptDisplay';
44+
declare type SlidedownEventName = 'slidedownShown';
45+
declare type OneSignalDeferredLoadedCallback = (onesignal: IOneSignalOneSignal) => void;
46+
interface IOSNotification {
47+
/**
48+
* The OneSignal notification id;
49+
* - Primary id on OneSignal's REST API and dashboard
50+
*/
51+
readonly notificationId: string;
52+
/**
53+
* Visible title text on the notification
54+
*/
55+
readonly title?: string;
56+
/**
57+
* Visible body text on the notification
58+
*/
59+
readonly body: string;
60+
/**
61+
* Visible icon the notification; URL format
62+
*/
63+
readonly icon?: string;
64+
/**
65+
* Visible small badgeIcon that displays on some devices; URL format
66+
* Example: On Android's status bar
67+
*/
68+
readonly badgeIcon?: string;
69+
/**
70+
* Visible image on the notification; URL format
71+
*/
72+
readonly image?: string;
73+
/**
74+
* Visible buttons on the notification
75+
*/
76+
readonly actionButtons?: IOSNotificationActionButton[];
77+
/**
78+
* If this value is the same as existing notification, it will replace it
79+
* Can be set when creating the notification with "Web Push Topic" on the dashboard
80+
* or web_push_topic from the REST API.
81+
*/
82+
readonly topic?: string;
83+
/**
84+
* Custom object that was sent with the notification;
85+
* definable when creating the notification from the OneSignal REST API or dashboard
86+
*/
87+
readonly additionalData?: object;
88+
/**
89+
* URL to open when clicking or tapping on the notification
90+
*/
91+
readonly launchURL?: string;
92+
/**
93+
* Confirm the push was received by reporting back to OneSignal
94+
*/
95+
readonly confirmDelivery: boolean;
96+
}
97+
interface IOSNotificationActionButton {
98+
/**
99+
* Any unique identifier to represent which button was clicked. This is typically passed back to the service worker
100+
* and host page through events to identify which button was clicked.
101+
* e.g. 'like-button'
102+
*/
103+
readonly actionId: string;
104+
/**
105+
* The notification action button's text.
106+
*/
107+
readonly text: string;
108+
/**
109+
* A valid publicly reachable HTTPS URL to an image.
110+
*/
111+
readonly icon?: string;
112+
/**
113+
* The URL to open the web browser to when this action button is clicked.
114+
*/
115+
readonly launchURL?: string;
116+
}
117+
interface NotificationClickResult {
118+
readonly actionId?: string;
119+
readonly url?: string;
120+
}
121+
declare type NotificationEventTypeMap = {
122+
'click': NotificationClickEvent;
123+
'foregroundWillDisplay': NotificationForegroundWillDisplayEvent;
124+
'dismiss': NotificationDismissEvent;
125+
'permissionChange': boolean;
126+
'permissionPromptDisplay': void;
127+
};
128+
interface NotificationForegroundWillDisplayEvent {
129+
readonly notification: IOSNotification;
130+
preventDefault(): void;
131+
}
132+
interface NotificationDismissEvent {
133+
notification: IOSNotification;
134+
}
135+
interface NotificationClickEvent {
136+
readonly notification: IOSNotification;
137+
readonly result: NotificationClickResult;
138+
}
139+
declare type UserChangeEvent = {
140+
current: UserNamespaceProperties;
141+
};
142+
declare type UserNamespaceProperties = {
143+
onesignalId: string | undefined;
144+
externalId: string | undefined;
145+
};
146+
interface IInitObject {
147+
appId: string;
148+
subdomainName?: string;
149+
requiresUserPrivacyConsent?: boolean;
150+
promptOptions?: object;
151+
welcomeNotification?: object;
152+
notifyButton?: object;
153+
persistNotification?: boolean;
154+
webhooks?: object;
155+
autoResubscribe?: boolean;
156+
autoRegister?: boolean;
157+
notificationClickHandlerMatch?: string;
158+
notificationClickHandlerAction?: string;
159+
path?: string;
160+
serviceWorkerParam?: {
161+
scope: string;
162+
};
163+
serviceWorkerPath?: string;
164+
serviceWorkerOverrideForTypical?: boolean;
165+
serviceWorkerUpdaterPath?: string;
166+
allowLocalhostAsSecureOrigin?: boolean;
167+
[key: string]: any;
168+
}
169+
interface IOneSignalOneSignal {
170+
Slidedown: IOneSignalSlidedown;
171+
Notifications: IOneSignalNotifications;
172+
Session: IOneSignalSession;
173+
User: IOneSignalUser;
174+
Debug: IOneSignalDebug;
175+
login(externalId: string, jwtToken?: string): Promise<void>;
176+
logout(): Promise<void>;
177+
init(options: IInitObject): Promise<void>;
178+
setConsentGiven(consent: boolean): Promise<void>;
179+
setConsentRequired(requiresConsent: boolean): Promise<void>;
180+
}
181+
interface IOneSignalNotifications {
182+
permissionNative: NotificationPermission;
183+
permission: boolean;
184+
setDefaultUrl(url: string): Promise<void>;
185+
setDefaultTitle(title: string): Promise<void>;
186+
isPushSupported(): boolean;
187+
requestPermission(): Promise<void>;
188+
addEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void;
189+
removeEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void;
190+
}
191+
interface IOneSignalSlidedown {
192+
promptPush(options?: AutoPromptOptions): Promise<void>;
193+
promptPushCategories(options?: AutoPromptOptions): Promise<void>;
194+
promptSms(options?: AutoPromptOptions): Promise<void>;
195+
promptEmail(options?: AutoPromptOptions): Promise<void>;
196+
promptSmsAndEmail(options?: AutoPromptOptions): Promise<void>;
197+
addEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
198+
removeEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
199+
}
200+
interface IOneSignalDebug {
201+
setLogLevel(logLevel: string): void;
202+
}
203+
interface IOneSignalSession {
204+
sendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void>;
205+
sendUniqueOutcome(outcomeName: string): Promise<void>;
206+
}
207+
interface IOneSignalUser {
208+
onesignalId: string | undefined;
209+
externalId: string | undefined;
210+
PushSubscription: IOneSignalPushSubscription;
211+
addAlias(label: string, id: string): void;
212+
addAliases(aliases: {
213+
[key: string]: string;
214+
}): void;
215+
removeAlias(label: string): void;
216+
removeAliases(labels: string[]): void;
217+
addEmail(email: string): void;
218+
removeEmail(email: string): void;
219+
addSms(smsNumber: string): void;
220+
removeSms(smsNumber: string): void;
221+
addTag(key: string, value: string): void;
222+
addTags(tags: {
223+
[key: string]: string;
224+
}): void;
225+
removeTag(key: string): void;
226+
removeTags(keys: string[]): void;
227+
getTags(): {
228+
[key: string]: string;
229+
};
230+
addEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void;
231+
removeEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void;
232+
setLanguage(language: string): void;
233+
getLanguage(): string;
234+
}
235+
interface IOneSignalPushSubscription {
236+
id: string | null | undefined;
237+
token: string | null | undefined;
238+
optedIn: boolean | undefined;
239+
optIn(): Promise<void>;
240+
optOut(): Promise<void>;
241+
addEventListener(event: 'change', listener: (change: SubscriptionChangeEvent) => void): void;
242+
removeEventListener(event: 'change', listener: (change: SubscriptionChangeEvent) => void): void;
243+
}
244+
declare const OneSignal: IOneSignalOneSignal;
245+
export default OneSignal;

0 commit comments

Comments
 (0)