@onesignal/onesignal-vue3 2.0.1 → 2.2.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.
- package/{.eslintrc.js → .eslintrc.cjs} +8 -14
- package/.github/os_probot_metadata.js +2 -2
- package/.github/workflows/release.yml +40 -0
- package/.releaserc.json +133 -0
- package/CHANGELOG.md +13 -0
- package/README.md +103 -76
- package/dist/index.d.ts +204 -30
- package/dist/index.js +89 -48
- package/dist/index.js.map +1 -1
- package/index.ts +378 -136
- package/package.json +11 -7
- package/tsconfig.json +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,18 +13,18 @@ declare global {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
interface AutoPromptOptions {
|
|
16
|
+
export interface AutoPromptOptions {
|
|
17
17
|
force?: boolean;
|
|
18
18
|
forceSlidedownOverNative?: boolean;
|
|
19
19
|
slidedownPromptOptions?: IOneSignalAutoPromptOptions;
|
|
20
20
|
}
|
|
21
|
-
interface IOneSignalAutoPromptOptions {
|
|
21
|
+
export interface IOneSignalAutoPromptOptions {
|
|
22
22
|
force?: boolean;
|
|
23
23
|
forceSlidedownOverNative?: boolean;
|
|
24
24
|
isInUpdateMode?: boolean;
|
|
25
25
|
categoryOptions?: IOneSignalCategories;
|
|
26
26
|
}
|
|
27
|
-
interface IOneSignalCategories {
|
|
27
|
+
export interface IOneSignalCategories {
|
|
28
28
|
positiveUpdateButton: string;
|
|
29
29
|
negativeUpdateButton: string;
|
|
30
30
|
savingButtonText: string;
|
|
@@ -32,24 +32,24 @@ interface IOneSignalCategories {
|
|
|
32
32
|
updateMessage: string;
|
|
33
33
|
tags: IOneSignalTagCategory[];
|
|
34
34
|
}
|
|
35
|
-
interface IOneSignalTagCategory {
|
|
35
|
+
export interface IOneSignalTagCategory {
|
|
36
36
|
tag: string;
|
|
37
37
|
label: string;
|
|
38
38
|
checked?: boolean;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
export type PushSubscriptionNamespaceProperties = {
|
|
41
41
|
id: string | null | undefined;
|
|
42
42
|
token: string | null | undefined;
|
|
43
43
|
optedIn: boolean;
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
export type SubscriptionChangeEvent = {
|
|
46
46
|
previous: PushSubscriptionNamespaceProperties;
|
|
47
47
|
current: PushSubscriptionNamespaceProperties;
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
interface IOSNotification {
|
|
49
|
+
export type NotificationEventName = 'click' | 'foregroundWillDisplay' | 'dismiss' | 'permissionChange' | 'permissionPromptDisplay';
|
|
50
|
+
export type SlidedownEventName = 'slidedownShown';
|
|
51
|
+
export type OneSignalDeferredLoadedCallback = (onesignal: IOneSignalOneSignal) => void;
|
|
52
|
+
export interface IOSNotification {
|
|
53
53
|
/**
|
|
54
54
|
* The OneSignal notification id;
|
|
55
55
|
* - Primary id on OneSignal's REST API and dashboard
|
|
@@ -84,7 +84,7 @@ interface IOSNotification {
|
|
|
84
84
|
* If this value is the same as existing notification, it will replace it
|
|
85
85
|
* Can be set when creating the notification with "Web Push Topic" on the dashboard
|
|
86
86
|
* or web_push_topic from the REST API.
|
|
87
|
-
|
|
87
|
+
*/
|
|
88
88
|
readonly topic?: string;
|
|
89
89
|
/**
|
|
90
90
|
* Custom object that was sent with the notification;
|
|
@@ -100,7 +100,7 @@ interface IOSNotification {
|
|
|
100
100
|
*/
|
|
101
101
|
readonly confirmDelivery: boolean;
|
|
102
102
|
}
|
|
103
|
-
interface IOSNotificationActionButton {
|
|
103
|
+
export interface IOSNotificationActionButton {
|
|
104
104
|
/**
|
|
105
105
|
* Any unique identifier to represent which button was clicked. This is typically passed back to the service worker
|
|
106
106
|
* and host page through events to identify which button was clicked.
|
|
@@ -120,51 +120,216 @@ interface IOSNotificationActionButton {
|
|
|
120
120
|
*/
|
|
121
121
|
readonly launchURL?: string;
|
|
122
122
|
}
|
|
123
|
-
interface NotificationClickResult {
|
|
123
|
+
export interface NotificationClickResult {
|
|
124
124
|
readonly actionId?: string;
|
|
125
125
|
readonly url?: string;
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
export type NotificationEventTypeMap = {
|
|
128
128
|
'click': NotificationClickEvent;
|
|
129
129
|
'foregroundWillDisplay': NotificationForegroundWillDisplayEvent;
|
|
130
130
|
'dismiss': NotificationDismissEvent;
|
|
131
131
|
'permissionChange': boolean;
|
|
132
132
|
'permissionPromptDisplay': void;
|
|
133
133
|
};
|
|
134
|
-
interface NotificationForegroundWillDisplayEvent {
|
|
134
|
+
export interface NotificationForegroundWillDisplayEvent {
|
|
135
135
|
readonly notification: IOSNotification;
|
|
136
136
|
preventDefault(): void;
|
|
137
137
|
}
|
|
138
|
-
interface NotificationDismissEvent {
|
|
138
|
+
export interface NotificationDismissEvent {
|
|
139
139
|
notification: IOSNotification;
|
|
140
140
|
}
|
|
141
|
-
interface NotificationClickEvent {
|
|
141
|
+
export interface NotificationClickEvent {
|
|
142
142
|
readonly notification: IOSNotification;
|
|
143
143
|
readonly result: NotificationClickResult;
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
export type UserChangeEvent = {
|
|
146
|
+
current: UserNamespaceProperties;
|
|
147
|
+
};
|
|
148
|
+
export type UserNamespaceProperties = {
|
|
149
|
+
onesignalId: string | undefined;
|
|
150
|
+
externalId: string | undefined;
|
|
151
|
+
};
|
|
152
|
+
export interface IInitObject {
|
|
146
153
|
appId: string;
|
|
147
154
|
subdomainName?: string;
|
|
148
155
|
requiresUserPrivacyConsent?: boolean;
|
|
149
|
-
promptOptions?:
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
promptOptions?: {
|
|
157
|
+
slidedown: {
|
|
158
|
+
prompts: {
|
|
159
|
+
/**
|
|
160
|
+
* Whether to automatically display the prompt.
|
|
161
|
+
* `true` will display the prompt based on the delay options.
|
|
162
|
+
* `false` will prevent the prompt from displaying until the Slidedowns methods are used.
|
|
163
|
+
*/
|
|
164
|
+
autoPrompt: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Only available for type: category. Up to 10 categories.
|
|
167
|
+
* @example
|
|
168
|
+
* categories: [{ tag: 'local_news', label: 'Local News' }] // The user will be tagged with local_news but will see "Local News" in the prompt.
|
|
169
|
+
*/
|
|
170
|
+
categories: {
|
|
171
|
+
/** Should identify the action. */
|
|
172
|
+
tag: string;
|
|
173
|
+
/** What the user will see. */
|
|
174
|
+
label: string;
|
|
175
|
+
}[];
|
|
176
|
+
/**
|
|
177
|
+
* The delay options for the prompt.
|
|
178
|
+
* @example delay: { pageViews: 3, timeDelay: 20 } // The user will not be shown the prompt until 20 seconds after the 3rd page view.
|
|
179
|
+
*/
|
|
180
|
+
delay: {
|
|
181
|
+
/** The number of pages a user needs to visit before the prompt is displayed. */
|
|
182
|
+
pageViews?: number;
|
|
183
|
+
/** The number of seconds a user needs to wait before the prompt is displayed.Both options must be satisfied for the prompt to display */
|
|
184
|
+
timeDelay?: number;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* The text to display in the prompt.
|
|
188
|
+
*/
|
|
189
|
+
text?: {
|
|
190
|
+
/** The callout asking the user to opt-in. Up to 90 characters. */
|
|
191
|
+
actionMessage?: string;
|
|
192
|
+
/** Triggers the opt-in. Up to 15 characters. */
|
|
193
|
+
acceptButton?: string;
|
|
194
|
+
/** Cancels opt-in. Up to 15 characters. */
|
|
195
|
+
cancelMessage?: string;
|
|
196
|
+
/** The message of the confirmation prompt displayed after the email and/or phone number is provided. Up to 90 characters. */
|
|
197
|
+
confirmMessage?: string;
|
|
198
|
+
/** Identifies the email text field. Up to 15 characters. */
|
|
199
|
+
emailLabel?: string;
|
|
200
|
+
/** Cancels the category update. Up to 15 characters. */
|
|
201
|
+
negativeUpdateButton?: string;
|
|
202
|
+
/** Saves the updated category tags. Up to 15 characters. */
|
|
203
|
+
positiveUpdateButton?: string;
|
|
204
|
+
/** Identifies the phone number text field. Up to 15 characters. */
|
|
205
|
+
smsLabel?: string;
|
|
206
|
+
/** A different message shown to subscribers presented the prompt again to update categories. Up to 90 characters. */
|
|
207
|
+
updateMessage?: string;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* The type of prompt to display.
|
|
211
|
+
* `push` which is the Slide Prompt without categories.
|
|
212
|
+
* `category` which is the Slide Prompt with categories.
|
|
213
|
+
* `sms` only asks for phone number.
|
|
214
|
+
* `email` only asks for email address.
|
|
215
|
+
* `smsAndEmail` asks for both phone number and email address.
|
|
216
|
+
*/
|
|
217
|
+
type: 'push' | 'category' | 'sms' | 'email' | 'smsAndEmail';
|
|
218
|
+
}[];
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
welcomeNotification?: {
|
|
222
|
+
/**
|
|
223
|
+
* Disables sending a welcome notification to new site visitors. If you want to disable welcome notifications, this is the only option you need.
|
|
224
|
+
*/
|
|
225
|
+
disabled?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* The welcome notification's message. You can localize this to your own language.
|
|
228
|
+
* If left blank or set to blank, the default of 'Thanks for subscribing!' will be used.
|
|
229
|
+
*/
|
|
230
|
+
message: string;
|
|
231
|
+
/**
|
|
232
|
+
* The welcome notification's title. You can localize this to your own language. If not set, or left blank, the site's title will be used.
|
|
233
|
+
* Set to one space ' ' to clear the title, although this is not recommended.
|
|
234
|
+
*/
|
|
235
|
+
title?: string;
|
|
236
|
+
/**
|
|
237
|
+
* By default, clicking the welcome notification does not open any link.
|
|
238
|
+
* This is recommended because the user has just visited your site and subscribed.
|
|
239
|
+
*/
|
|
240
|
+
url: string;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Will enable customization of the notify/subscription bell button.
|
|
244
|
+
*/
|
|
245
|
+
notifyButton?: {
|
|
246
|
+
/**
|
|
247
|
+
* A function you define that returns true to show the Subscription Bell, or false to hide it.
|
|
248
|
+
* Typically used the hide the Subscription Bell after the user is subscribed.
|
|
249
|
+
* This function is not re-evaluated on every state change; this function is only evaluated once when the Subscription Bell begins to show.
|
|
250
|
+
*/
|
|
251
|
+
displayPredicate?: () => boolean | Promise<boolean>;
|
|
252
|
+
/**
|
|
253
|
+
* Enable the Subscription Bell. The Subscription Bell is otherwise disabled by default.
|
|
254
|
+
*/
|
|
255
|
+
enable?: boolean;
|
|
256
|
+
/** Specify CSS-valid pixel offsets using bottom, left, and right. */
|
|
257
|
+
offset?: {
|
|
258
|
+
bottom: string;
|
|
259
|
+
left: string;
|
|
260
|
+
right: string;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* If `true`, the Subscription Bell will display an icon that there is 1 unread message.
|
|
264
|
+
* When hovering over the Subscription Bell, the user will see custom text set by message.prenotify.
|
|
265
|
+
*/
|
|
266
|
+
prenotify: boolean;
|
|
267
|
+
/** Either `bottom-left` or `bottom-right`. The Subscription Bell will be fixed at this location on your page. */
|
|
268
|
+
position?: 'bottom-left' | 'bottom-right';
|
|
269
|
+
/** Set `false` to hide the 'Powered by OneSignal' text in the Subscription Bell dialog popup. */
|
|
270
|
+
showCredit: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* The Subscription Bell will initially appear at one of these sizes, and then shrink down to size `small` after the user subscribes.
|
|
273
|
+
*/
|
|
274
|
+
size?: 'small' | 'medium' | 'large';
|
|
275
|
+
/** Customize the Subscription Bell text. */
|
|
276
|
+
text: {
|
|
277
|
+
'dialog.blocked.message': string;
|
|
278
|
+
'dialog.blocked.title': string;
|
|
279
|
+
'dialog.main.button.subscribe': string;
|
|
280
|
+
'dialog.main.button.unsubscribe': string;
|
|
281
|
+
'dialog.main.title': string;
|
|
282
|
+
'message.action.resubscribed': string;
|
|
283
|
+
'message.action.subscribed': string;
|
|
284
|
+
'message.action.subscribing': string;
|
|
285
|
+
'message.action.unsubscribed': string;
|
|
286
|
+
'message.prenotify': string;
|
|
287
|
+
'tip.state.blocked': string;
|
|
288
|
+
'tip.state.subscribed': string;
|
|
289
|
+
'tip.state.unsubscribed': string;
|
|
290
|
+
};
|
|
291
|
+
};
|
|
152
292
|
persistNotification?: boolean;
|
|
153
|
-
webhooks?:
|
|
293
|
+
webhooks?: {
|
|
294
|
+
/**
|
|
295
|
+
* Enable this setting only if your server has CORS enabled and supports non-simple CORS requests.
|
|
296
|
+
* If this setting is disabled, your webhook will not need CORS to receive data, but it will not receive the custom headers.
|
|
297
|
+
* The simplest option is to leave it disabled.
|
|
298
|
+
* @default false
|
|
299
|
+
*/
|
|
300
|
+
cors: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* This event occurs after a notification is clicked.
|
|
303
|
+
* @example https://site.com/hook
|
|
304
|
+
*/
|
|
305
|
+
'notification.clicked'?: string;
|
|
306
|
+
/**
|
|
307
|
+
* This event occurs after a notification is intentionally dismissed by the user (clicking the notification body or one of the notification action buttons does not trigger the dismissed webhook),
|
|
308
|
+
* after a group of notifications are all dismissed (with this notification as part of that group), or after a notification expires on its own time and disappears. This event is supported on Chrome only.
|
|
309
|
+
* @example https://site.com/hook
|
|
310
|
+
*/
|
|
311
|
+
'notification.dismissed'?: string;
|
|
312
|
+
/**
|
|
313
|
+
* This event occurs after a notification is displayed.
|
|
314
|
+
* @example https://site.com/hook
|
|
315
|
+
*/
|
|
316
|
+
'notification.willDisplay'?: string;
|
|
317
|
+
};
|
|
154
318
|
autoResubscribe?: boolean;
|
|
155
319
|
autoRegister?: boolean;
|
|
156
320
|
notificationClickHandlerMatch?: string;
|
|
157
321
|
notificationClickHandlerAction?: string;
|
|
322
|
+
path?: string;
|
|
158
323
|
serviceWorkerParam?: {
|
|
159
324
|
scope: string;
|
|
160
325
|
};
|
|
161
326
|
serviceWorkerPath?: string;
|
|
327
|
+
serviceWorkerOverrideForTypical?: boolean;
|
|
162
328
|
serviceWorkerUpdaterPath?: string;
|
|
163
|
-
path?: string;
|
|
164
329
|
allowLocalhostAsSecureOrigin?: boolean;
|
|
165
330
|
[key: string]: any;
|
|
166
331
|
}
|
|
167
|
-
interface IOneSignalOneSignal {
|
|
332
|
+
export interface IOneSignalOneSignal {
|
|
168
333
|
Slidedown: IOneSignalSlidedown;
|
|
169
334
|
Notifications: IOneSignalNotifications;
|
|
170
335
|
Session: IOneSignalSession;
|
|
@@ -176,7 +341,7 @@ interface IOneSignalOneSignal {
|
|
|
176
341
|
setConsentGiven(consent: boolean): Promise<void>;
|
|
177
342
|
setConsentRequired(requiresConsent: boolean): Promise<void>;
|
|
178
343
|
}
|
|
179
|
-
interface IOneSignalNotifications {
|
|
344
|
+
export interface IOneSignalNotifications {
|
|
180
345
|
permissionNative: NotificationPermission;
|
|
181
346
|
permission: boolean;
|
|
182
347
|
setDefaultUrl(url: string): Promise<void>;
|
|
@@ -186,7 +351,7 @@ interface IOneSignalNotifications {
|
|
|
186
351
|
addEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void;
|
|
187
352
|
removeEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void;
|
|
188
353
|
}
|
|
189
|
-
interface IOneSignalSlidedown {
|
|
354
|
+
export interface IOneSignalSlidedown {
|
|
190
355
|
promptPush(options?: AutoPromptOptions): Promise<void>;
|
|
191
356
|
promptPushCategories(options?: AutoPromptOptions): Promise<void>;
|
|
192
357
|
promptSms(options?: AutoPromptOptions): Promise<void>;
|
|
@@ -195,14 +360,16 @@ interface IOneSignalSlidedown {
|
|
|
195
360
|
addEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
|
|
196
361
|
removeEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
|
|
197
362
|
}
|
|
198
|
-
interface IOneSignalDebug {
|
|
363
|
+
export interface IOneSignalDebug {
|
|
199
364
|
setLogLevel(logLevel: string): void;
|
|
200
365
|
}
|
|
201
|
-
interface IOneSignalSession {
|
|
366
|
+
export interface IOneSignalSession {
|
|
202
367
|
sendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void>;
|
|
203
368
|
sendUniqueOutcome(outcomeName: string): Promise<void>;
|
|
204
369
|
}
|
|
205
|
-
interface IOneSignalUser {
|
|
370
|
+
export interface IOneSignalUser {
|
|
371
|
+
onesignalId: string | undefined;
|
|
372
|
+
externalId: string | undefined;
|
|
206
373
|
PushSubscription: IOneSignalPushSubscription;
|
|
207
374
|
addAlias(label: string, id: string): void;
|
|
208
375
|
addAliases(aliases: {
|
|
@@ -220,8 +387,15 @@ interface IOneSignalUser {
|
|
|
220
387
|
}): void;
|
|
221
388
|
removeTag(key: string): void;
|
|
222
389
|
removeTags(keys: string[]): void;
|
|
390
|
+
getTags(): {
|
|
391
|
+
[key: string]: string;
|
|
392
|
+
};
|
|
393
|
+
addEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void;
|
|
394
|
+
removeEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void;
|
|
395
|
+
setLanguage(language: string): void;
|
|
396
|
+
getLanguage(): string;
|
|
223
397
|
}
|
|
224
|
-
interface IOneSignalPushSubscription {
|
|
398
|
+
export interface IOneSignalPushSubscription {
|
|
225
399
|
id: string | null | undefined;
|
|
226
400
|
token: string | null | undefined;
|
|
227
401
|
optedIn: boolean | undefined;
|
package/dist/index.js
CHANGED
|
@@ -85,12 +85,12 @@ function oneSignalLogin(externalId, jwtToken) {
|
|
|
85
85
|
return new Promise(function (resolve, reject) {
|
|
86
86
|
var _a;
|
|
87
87
|
if (isOneSignalScriptFailed) {
|
|
88
|
-
reject();
|
|
88
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
89
|
+
return;
|
|
89
90
|
}
|
|
90
91
|
try {
|
|
91
92
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
92
|
-
OneSignal.login(externalId, jwtToken)
|
|
93
|
-
.then(value => resolve(value))
|
|
93
|
+
OneSignal.login(externalId, jwtToken).then(() => resolve())
|
|
94
94
|
.catch(error => reject(error));
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -103,12 +103,12 @@ function oneSignalLogout() {
|
|
|
103
103
|
return new Promise(function (resolve, reject) {
|
|
104
104
|
var _a;
|
|
105
105
|
if (isOneSignalScriptFailed) {
|
|
106
|
-
reject();
|
|
106
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
107
|
+
return;
|
|
107
108
|
}
|
|
108
109
|
try {
|
|
109
110
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
110
|
-
OneSignal.logout()
|
|
111
|
-
.then(value => resolve(value))
|
|
111
|
+
OneSignal.logout().then(() => resolve())
|
|
112
112
|
.catch(error => reject(error));
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -121,12 +121,12 @@ function oneSignalSetConsentGiven(consent) {
|
|
|
121
121
|
return new Promise(function (resolve, reject) {
|
|
122
122
|
var _a;
|
|
123
123
|
if (isOneSignalScriptFailed) {
|
|
124
|
-
reject();
|
|
124
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
125
|
+
return;
|
|
125
126
|
}
|
|
126
127
|
try {
|
|
127
128
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
128
|
-
OneSignal.setConsentGiven(consent)
|
|
129
|
-
.then(value => resolve(value))
|
|
129
|
+
OneSignal.setConsentGiven(consent).then(() => resolve())
|
|
130
130
|
.catch(error => reject(error));
|
|
131
131
|
});
|
|
132
132
|
}
|
|
@@ -139,12 +139,12 @@ function oneSignalSetConsentRequired(requiresConsent) {
|
|
|
139
139
|
return new Promise(function (resolve, reject) {
|
|
140
140
|
var _a;
|
|
141
141
|
if (isOneSignalScriptFailed) {
|
|
142
|
-
reject();
|
|
142
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
143
|
+
return;
|
|
143
144
|
}
|
|
144
145
|
try {
|
|
145
146
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
146
|
-
OneSignal.setConsentRequired(requiresConsent)
|
|
147
|
-
.then(value => resolve(value))
|
|
147
|
+
OneSignal.setConsentRequired(requiresConsent).then(() => resolve())
|
|
148
148
|
.catch(error => reject(error));
|
|
149
149
|
});
|
|
150
150
|
}
|
|
@@ -157,12 +157,12 @@ function slidedownPromptPush(options) {
|
|
|
157
157
|
return new Promise(function (resolve, reject) {
|
|
158
158
|
var _a;
|
|
159
159
|
if (isOneSignalScriptFailed) {
|
|
160
|
-
reject();
|
|
160
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
161
|
+
return;
|
|
161
162
|
}
|
|
162
163
|
try {
|
|
163
164
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
164
|
-
OneSignal.Slidedown.promptPush(options)
|
|
165
|
-
.then(value => resolve(value))
|
|
165
|
+
OneSignal.Slidedown.promptPush(options).then(() => resolve())
|
|
166
166
|
.catch(error => reject(error));
|
|
167
167
|
});
|
|
168
168
|
}
|
|
@@ -175,12 +175,12 @@ function slidedownPromptPushCategories(options) {
|
|
|
175
175
|
return new Promise(function (resolve, reject) {
|
|
176
176
|
var _a;
|
|
177
177
|
if (isOneSignalScriptFailed) {
|
|
178
|
-
reject();
|
|
178
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
179
|
+
return;
|
|
179
180
|
}
|
|
180
181
|
try {
|
|
181
182
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
182
|
-
OneSignal.Slidedown.promptPushCategories(options)
|
|
183
|
-
.then(value => resolve(value))
|
|
183
|
+
OneSignal.Slidedown.promptPushCategories(options).then(() => resolve())
|
|
184
184
|
.catch(error => reject(error));
|
|
185
185
|
});
|
|
186
186
|
}
|
|
@@ -193,12 +193,12 @@ function slidedownPromptSms(options) {
|
|
|
193
193
|
return new Promise(function (resolve, reject) {
|
|
194
194
|
var _a;
|
|
195
195
|
if (isOneSignalScriptFailed) {
|
|
196
|
-
reject();
|
|
196
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
197
|
+
return;
|
|
197
198
|
}
|
|
198
199
|
try {
|
|
199
200
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
200
|
-
OneSignal.Slidedown.promptSms(options)
|
|
201
|
-
.then(value => resolve(value))
|
|
201
|
+
OneSignal.Slidedown.promptSms(options).then(() => resolve())
|
|
202
202
|
.catch(error => reject(error));
|
|
203
203
|
});
|
|
204
204
|
}
|
|
@@ -211,12 +211,12 @@ function slidedownPromptEmail(options) {
|
|
|
211
211
|
return new Promise(function (resolve, reject) {
|
|
212
212
|
var _a;
|
|
213
213
|
if (isOneSignalScriptFailed) {
|
|
214
|
-
reject();
|
|
214
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
215
|
+
return;
|
|
215
216
|
}
|
|
216
217
|
try {
|
|
217
218
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
218
|
-
OneSignal.Slidedown.promptEmail(options)
|
|
219
|
-
.then(value => resolve(value))
|
|
219
|
+
OneSignal.Slidedown.promptEmail(options).then(() => resolve())
|
|
220
220
|
.catch(error => reject(error));
|
|
221
221
|
});
|
|
222
222
|
}
|
|
@@ -229,12 +229,12 @@ function slidedownPromptSmsAndEmail(options) {
|
|
|
229
229
|
return new Promise(function (resolve, reject) {
|
|
230
230
|
var _a;
|
|
231
231
|
if (isOneSignalScriptFailed) {
|
|
232
|
-
reject();
|
|
232
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
233
|
+
return;
|
|
233
234
|
}
|
|
234
235
|
try {
|
|
235
236
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
236
|
-
OneSignal.Slidedown.promptSmsAndEmail(options)
|
|
237
|
-
.then(value => resolve(value))
|
|
237
|
+
OneSignal.Slidedown.promptSmsAndEmail(options).then(() => resolve())
|
|
238
238
|
.catch(error => reject(error));
|
|
239
239
|
});
|
|
240
240
|
}
|
|
@@ -259,12 +259,12 @@ function notificationsSetDefaultUrl(url) {
|
|
|
259
259
|
return new Promise(function (resolve, reject) {
|
|
260
260
|
var _a;
|
|
261
261
|
if (isOneSignalScriptFailed) {
|
|
262
|
-
reject();
|
|
262
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
263
|
+
return;
|
|
263
264
|
}
|
|
264
265
|
try {
|
|
265
266
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
266
|
-
OneSignal.Notifications.setDefaultUrl(url)
|
|
267
|
-
.then(value => resolve(value))
|
|
267
|
+
OneSignal.Notifications.setDefaultUrl(url).then(() => resolve())
|
|
268
268
|
.catch(error => reject(error));
|
|
269
269
|
});
|
|
270
270
|
}
|
|
@@ -277,12 +277,12 @@ function notificationsSetDefaultTitle(title) {
|
|
|
277
277
|
return new Promise(function (resolve, reject) {
|
|
278
278
|
var _a;
|
|
279
279
|
if (isOneSignalScriptFailed) {
|
|
280
|
-
reject();
|
|
280
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
281
|
+
return;
|
|
281
282
|
}
|
|
282
283
|
try {
|
|
283
284
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
284
|
-
OneSignal.Notifications.setDefaultTitle(title)
|
|
285
|
-
.then(value => resolve(value))
|
|
285
|
+
OneSignal.Notifications.setDefaultTitle(title).then(() => resolve())
|
|
286
286
|
.catch(error => reject(error));
|
|
287
287
|
});
|
|
288
288
|
}
|
|
@@ -295,12 +295,12 @@ function notificationsRequestPermission() {
|
|
|
295
295
|
return new Promise(function (resolve, reject) {
|
|
296
296
|
var _a;
|
|
297
297
|
if (isOneSignalScriptFailed) {
|
|
298
|
-
reject();
|
|
298
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
299
|
+
return;
|
|
299
300
|
}
|
|
300
301
|
try {
|
|
301
302
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
302
|
-
OneSignal.Notifications.requestPermission()
|
|
303
|
-
.then(value => resolve(value))
|
|
303
|
+
OneSignal.Notifications.requestPermission().then(() => resolve())
|
|
304
304
|
.catch(error => reject(error));
|
|
305
305
|
});
|
|
306
306
|
}
|
|
@@ -325,12 +325,12 @@ function sessionSendOutcome(outcomeName, outcomeWeight) {
|
|
|
325
325
|
return new Promise(function (resolve, reject) {
|
|
326
326
|
var _a;
|
|
327
327
|
if (isOneSignalScriptFailed) {
|
|
328
|
-
reject();
|
|
328
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
329
|
+
return;
|
|
329
330
|
}
|
|
330
331
|
try {
|
|
331
332
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
332
|
-
OneSignal.Session.sendOutcome(outcomeName, outcomeWeight)
|
|
333
|
-
.then(value => resolve(value))
|
|
333
|
+
OneSignal.Session.sendOutcome(outcomeName, outcomeWeight).then(() => resolve())
|
|
334
334
|
.catch(error => reject(error));
|
|
335
335
|
});
|
|
336
336
|
}
|
|
@@ -343,12 +343,12 @@ function sessionSendUniqueOutcome(outcomeName) {
|
|
|
343
343
|
return new Promise(function (resolve, reject) {
|
|
344
344
|
var _a;
|
|
345
345
|
if (isOneSignalScriptFailed) {
|
|
346
|
-
reject();
|
|
346
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
347
|
+
return;
|
|
347
348
|
}
|
|
348
349
|
try {
|
|
349
350
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
350
|
-
OneSignal.Session.sendUniqueOutcome(outcomeName)
|
|
351
|
-
.then(value => resolve(value))
|
|
351
|
+
OneSignal.Session.sendUniqueOutcome(outcomeName).then(() => resolve())
|
|
352
352
|
.catch(error => reject(error));
|
|
353
353
|
});
|
|
354
354
|
}
|
|
@@ -429,16 +429,50 @@ function userRemoveTags(keys) {
|
|
|
429
429
|
OneSignal.User.removeTags(keys);
|
|
430
430
|
});
|
|
431
431
|
}
|
|
432
|
+
function userGetTags() {
|
|
433
|
+
var _a;
|
|
434
|
+
let retVal;
|
|
435
|
+
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
436
|
+
retVal = OneSignal.User.getTags();
|
|
437
|
+
});
|
|
438
|
+
return retVal;
|
|
439
|
+
}
|
|
440
|
+
function userAddEventListener(event, listener) {
|
|
441
|
+
var _a;
|
|
442
|
+
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
443
|
+
OneSignal.User.addEventListener(event, listener);
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
function userRemoveEventListener(event, listener) {
|
|
447
|
+
var _a;
|
|
448
|
+
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
449
|
+
OneSignal.User.removeEventListener(event, listener);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function userSetLanguage(language) {
|
|
453
|
+
var _a;
|
|
454
|
+
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
455
|
+
OneSignal.User.setLanguage(language);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function userGetLanguage() {
|
|
459
|
+
var _a;
|
|
460
|
+
let retVal;
|
|
461
|
+
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
462
|
+
retVal = OneSignal.User.getLanguage();
|
|
463
|
+
});
|
|
464
|
+
return retVal;
|
|
465
|
+
}
|
|
432
466
|
function pushSubscriptionOptIn() {
|
|
433
467
|
return new Promise(function (resolve, reject) {
|
|
434
468
|
var _a;
|
|
435
469
|
if (isOneSignalScriptFailed) {
|
|
436
|
-
reject();
|
|
470
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
471
|
+
return;
|
|
437
472
|
}
|
|
438
473
|
try {
|
|
439
474
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
440
|
-
OneSignal.User.PushSubscription.optIn()
|
|
441
|
-
.then(value => resolve(value))
|
|
475
|
+
OneSignal.User.PushSubscription.optIn().then(() => resolve())
|
|
442
476
|
.catch(error => reject(error));
|
|
443
477
|
});
|
|
444
478
|
}
|
|
@@ -451,12 +485,12 @@ function pushSubscriptionOptOut() {
|
|
|
451
485
|
return new Promise(function (resolve, reject) {
|
|
452
486
|
var _a;
|
|
453
487
|
if (isOneSignalScriptFailed) {
|
|
454
|
-
reject();
|
|
488
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
489
|
+
return;
|
|
455
490
|
}
|
|
456
491
|
try {
|
|
457
492
|
(_a = window.OneSignalDeferred) === null || _a === void 0 ? void 0 : _a.push((OneSignal) => {
|
|
458
|
-
OneSignal.User.PushSubscription.optOut()
|
|
459
|
-
.then(value => resolve(value))
|
|
493
|
+
OneSignal.User.PushSubscription.optOut().then(() => resolve())
|
|
460
494
|
.catch(error => reject(error));
|
|
461
495
|
});
|
|
462
496
|
}
|
|
@@ -493,6 +527,8 @@ const PushSubscriptionNamespace = {
|
|
|
493
527
|
removeEventListener: pushSubscriptionRemoveEventListener,
|
|
494
528
|
};
|
|
495
529
|
const UserNamespace = {
|
|
530
|
+
get onesignalId() { var _a, _b; return (_b = (_a = window.OneSignal) === null || _a === void 0 ? void 0 : _a.User) === null || _b === void 0 ? void 0 : _b.onesignalId; },
|
|
531
|
+
get externalId() { var _a, _b; return (_b = (_a = window.OneSignal) === null || _a === void 0 ? void 0 : _a.User) === null || _b === void 0 ? void 0 : _b.externalId; },
|
|
496
532
|
addAlias: userAddAlias,
|
|
497
533
|
addAliases: userAddAliases,
|
|
498
534
|
removeAlias: userRemoveAlias,
|
|
@@ -505,6 +541,11 @@ const UserNamespace = {
|
|
|
505
541
|
addTags: userAddTags,
|
|
506
542
|
removeTag: userRemoveTag,
|
|
507
543
|
removeTags: userRemoveTags,
|
|
544
|
+
getTags: userGetTags,
|
|
545
|
+
addEventListener: userAddEventListener,
|
|
546
|
+
removeEventListener: userRemoveEventListener,
|
|
547
|
+
setLanguage: userSetLanguage,
|
|
548
|
+
getLanguage: userGetLanguage,
|
|
508
549
|
PushSubscription: PushSubscriptionNamespace,
|
|
509
550
|
};
|
|
510
551
|
const SessionNamespace = {
|