onesignal-vue 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.cjs +38 -0
- package/.github/workflows/release.yml +40 -0
- package/.releaserc.json +133 -0
- package/CHANGELOG.md +13 -0
- package/README.md +98 -81
- 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 +5 -5
- package/tsconfig.json +0 -1
- package/.eslintrc.js +0 -44
package/index.ts
CHANGED
|
@@ -121,16 +121,16 @@ const isPushSupported = (): boolean => {
|
|
|
121
121
|
return isPushNotificationsSupported();
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
interface AutoPromptOptions { force?: boolean; forceSlidedownOverNative?: boolean; slidedownPromptOptions?: IOneSignalAutoPromptOptions; }
|
|
125
|
-
interface IOneSignalAutoPromptOptions { force?: boolean; forceSlidedownOverNative?: boolean; isInUpdateMode?: boolean; categoryOptions?: IOneSignalCategories; }
|
|
126
|
-
interface IOneSignalCategories { positiveUpdateButton: string; negativeUpdateButton: string; savingButtonText: string; errorButtonText: string; updateMessage: string; tags: IOneSignalTagCategory[]; }
|
|
127
|
-
interface IOneSignalTagCategory { tag: string; label: string; checked?: boolean; }
|
|
128
|
-
type PushSubscriptionNamespaceProperties = { id: string | null | undefined; token: string | null | undefined; optedIn: boolean; };
|
|
129
|
-
type SubscriptionChangeEvent = { previous: PushSubscriptionNamespaceProperties; current: PushSubscriptionNamespaceProperties; };
|
|
130
|
-
type NotificationEventName = 'click' | 'foregroundWillDisplay' | 'dismiss' | 'permissionChange' | 'permissionPromptDisplay';
|
|
131
|
-
type SlidedownEventName = 'slidedownShown';
|
|
132
|
-
type OneSignalDeferredLoadedCallback = (onesignal: IOneSignalOneSignal) => void;
|
|
133
|
-
interface IOSNotification {
|
|
124
|
+
export interface AutoPromptOptions { force?: boolean; forceSlidedownOverNative?: boolean; slidedownPromptOptions?: IOneSignalAutoPromptOptions; }
|
|
125
|
+
export interface IOneSignalAutoPromptOptions { force?: boolean; forceSlidedownOverNative?: boolean; isInUpdateMode?: boolean; categoryOptions?: IOneSignalCategories; }
|
|
126
|
+
export interface IOneSignalCategories { positiveUpdateButton: string; negativeUpdateButton: string; savingButtonText: string; errorButtonText: string; updateMessage: string; tags: IOneSignalTagCategory[]; }
|
|
127
|
+
export interface IOneSignalTagCategory { tag: string; label: string; checked?: boolean; }
|
|
128
|
+
export type PushSubscriptionNamespaceProperties = { id: string | null | undefined; token: string | null | undefined; optedIn: boolean; };
|
|
129
|
+
export type SubscriptionChangeEvent = { previous: PushSubscriptionNamespaceProperties; current: PushSubscriptionNamespaceProperties; };
|
|
130
|
+
export type NotificationEventName = 'click' | 'foregroundWillDisplay' | 'dismiss' | 'permissionChange' | 'permissionPromptDisplay';
|
|
131
|
+
export type SlidedownEventName = 'slidedownShown';
|
|
132
|
+
export type OneSignalDeferredLoadedCallback = (onesignal: IOneSignalOneSignal) => void;
|
|
133
|
+
export interface IOSNotification {
|
|
134
134
|
/**
|
|
135
135
|
* The OneSignal notification id;
|
|
136
136
|
* - Primary id on OneSignal's REST API and dashboard
|
|
@@ -172,7 +172,7 @@ interface IOSNotification {
|
|
|
172
172
|
* If this value is the same as existing notification, it will replace it
|
|
173
173
|
* Can be set when creating the notification with "Web Push Topic" on the dashboard
|
|
174
174
|
* or web_push_topic from the REST API.
|
|
175
|
-
|
|
175
|
+
*/
|
|
176
176
|
readonly topic?: string;
|
|
177
177
|
|
|
178
178
|
/**
|
|
@@ -192,7 +192,7 @@ interface IOSNotification {
|
|
|
192
192
|
readonly confirmDelivery: boolean;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
interface IOSNotificationActionButton {
|
|
195
|
+
export interface IOSNotificationActionButton {
|
|
196
196
|
/**
|
|
197
197
|
* Any unique identifier to represent which button was clicked. This is typically passed back to the service worker
|
|
198
198
|
* and host page through events to identify which button was clicked.
|
|
@@ -213,56 +213,246 @@ interface IOSNotificationActionButton {
|
|
|
213
213
|
readonly launchURL?: string;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
interface NotificationClickResult {
|
|
216
|
+
export interface NotificationClickResult {
|
|
217
217
|
readonly actionId?: string;
|
|
218
218
|
readonly url?: string;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
type NotificationEventTypeMap = {
|
|
221
|
+
export type NotificationEventTypeMap = {
|
|
222
222
|
'click': NotificationClickEvent;
|
|
223
223
|
'foregroundWillDisplay': NotificationForegroundWillDisplayEvent;
|
|
224
224
|
'dismiss': NotificationDismissEvent;
|
|
225
225
|
'permissionChange': boolean;
|
|
226
226
|
'permissionPromptDisplay': void;
|
|
227
|
-
}
|
|
227
|
+
};
|
|
228
228
|
|
|
229
|
-
interface NotificationForegroundWillDisplayEvent {
|
|
229
|
+
export interface NotificationForegroundWillDisplayEvent {
|
|
230
230
|
readonly notification: IOSNotification;
|
|
231
231
|
preventDefault(): void;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
interface NotificationDismissEvent {
|
|
234
|
+
export interface NotificationDismissEvent {
|
|
235
235
|
notification: IOSNotification;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
interface NotificationClickEvent {
|
|
238
|
+
export interface NotificationClickEvent {
|
|
239
239
|
readonly notification: IOSNotification;
|
|
240
240
|
readonly result: NotificationClickResult;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
export type UserChangeEvent = {
|
|
244
|
+
current: UserNamespaceProperties;
|
|
245
|
+
};
|
|
246
|
+
export type UserNamespaceProperties = {
|
|
247
|
+
onesignalId: string | undefined;
|
|
248
|
+
externalId: string | undefined;
|
|
249
|
+
};
|
|
243
250
|
|
|
244
|
-
interface IInitObject {
|
|
251
|
+
export interface IInitObject {
|
|
245
252
|
appId: string;
|
|
246
253
|
subdomainName?: string;
|
|
247
254
|
requiresUserPrivacyConsent?: boolean;
|
|
248
|
-
promptOptions?:
|
|
249
|
-
|
|
250
|
-
|
|
255
|
+
promptOptions?: {
|
|
256
|
+
slidedown: {
|
|
257
|
+
prompts: {
|
|
258
|
+
/**
|
|
259
|
+
* Whether to automatically display the prompt.
|
|
260
|
+
* `true` will display the prompt based on the delay options.
|
|
261
|
+
* `false` will prevent the prompt from displaying until the Slidedowns methods are used.
|
|
262
|
+
*/
|
|
263
|
+
autoPrompt: boolean;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Only available for type: category. Up to 10 categories.
|
|
267
|
+
* @example
|
|
268
|
+
* categories: [{ tag: 'local_news', label: 'Local News' }] // The user will be tagged with local_news but will see "Local News" in the prompt.
|
|
269
|
+
*/
|
|
270
|
+
categories: {
|
|
271
|
+
/** Should identify the action. */
|
|
272
|
+
tag: string;
|
|
273
|
+
|
|
274
|
+
/** What the user will see. */
|
|
275
|
+
label: string;
|
|
276
|
+
}[];
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* The delay options for the prompt.
|
|
280
|
+
* @example delay: { pageViews: 3, timeDelay: 20 } // The user will not be shown the prompt until 20 seconds after the 3rd page view.
|
|
281
|
+
*/
|
|
282
|
+
delay: {
|
|
283
|
+
/** The number of pages a user needs to visit before the prompt is displayed. */
|
|
284
|
+
pageViews?: number;
|
|
285
|
+
|
|
286
|
+
/** The number of seconds a user needs to wait before the prompt is displayed.Both options must be satisfied for the prompt to display */
|
|
287
|
+
timeDelay?: number;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The text to display in the prompt.
|
|
292
|
+
*/
|
|
293
|
+
text?: {
|
|
294
|
+
/** The callout asking the user to opt-in. Up to 90 characters. */
|
|
295
|
+
actionMessage?: string;
|
|
296
|
+
|
|
297
|
+
/** Triggers the opt-in. Up to 15 characters. */
|
|
298
|
+
acceptButton?: string;
|
|
299
|
+
|
|
300
|
+
/** Cancels opt-in. Up to 15 characters. */
|
|
301
|
+
cancelMessage?: string;
|
|
302
|
+
|
|
303
|
+
/** The message of the confirmation prompt displayed after the email and/or phone number is provided. Up to 90 characters. */
|
|
304
|
+
confirmMessage?: string;
|
|
305
|
+
|
|
306
|
+
/** Identifies the email text field. Up to 15 characters. */
|
|
307
|
+
emailLabel?: string;
|
|
308
|
+
|
|
309
|
+
/** Cancels the category update. Up to 15 characters. */
|
|
310
|
+
negativeUpdateButton?: string;
|
|
311
|
+
|
|
312
|
+
/** Saves the updated category tags. Up to 15 characters. */
|
|
313
|
+
positiveUpdateButton?: string;
|
|
314
|
+
|
|
315
|
+
/** Identifies the phone number text field. Up to 15 characters. */
|
|
316
|
+
smsLabel?: string;
|
|
317
|
+
|
|
318
|
+
/** A different message shown to subscribers presented the prompt again to update categories. Up to 90 characters. */
|
|
319
|
+
updateMessage?: string;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The type of prompt to display.
|
|
324
|
+
* `push` which is the Slide Prompt without categories.
|
|
325
|
+
* `category` which is the Slide Prompt with categories.
|
|
326
|
+
* `sms` only asks for phone number.
|
|
327
|
+
* `email` only asks for email address.
|
|
328
|
+
* `smsAndEmail` asks for both phone number and email address.
|
|
329
|
+
*/
|
|
330
|
+
type: 'push' | 'category' | 'sms' | 'email' | 'smsAndEmail';
|
|
331
|
+
}[];
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
welcomeNotification?: {
|
|
335
|
+
/**
|
|
336
|
+
* Disables sending a welcome notification to new site visitors. If you want to disable welcome notifications, this is the only option you need.
|
|
337
|
+
*/
|
|
338
|
+
disabled?: boolean;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* The welcome notification's message. You can localize this to your own language.
|
|
342
|
+
* If left blank or set to blank, the default of 'Thanks for subscribing!' will be used.
|
|
343
|
+
*/
|
|
344
|
+
message: string;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* 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.
|
|
348
|
+
* Set to one space ' ' to clear the title, although this is not recommended.
|
|
349
|
+
*/
|
|
350
|
+
title?: string;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* By default, clicking the welcome notification does not open any link.
|
|
354
|
+
* This is recommended because the user has just visited your site and subscribed.
|
|
355
|
+
*/
|
|
356
|
+
url: string;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Will enable customization of the notify/subscription bell button.
|
|
361
|
+
*/
|
|
362
|
+
notifyButton?: {
|
|
363
|
+
/**
|
|
364
|
+
* A function you define that returns true to show the Subscription Bell, or false to hide it.
|
|
365
|
+
* Typically used the hide the Subscription Bell after the user is subscribed.
|
|
366
|
+
* This function is not re-evaluated on every state change; this function is only evaluated once when the Subscription Bell begins to show.
|
|
367
|
+
*/
|
|
368
|
+
displayPredicate?: () => boolean | Promise<boolean>;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Enable the Subscription Bell. The Subscription Bell is otherwise disabled by default.
|
|
372
|
+
*/
|
|
373
|
+
enable?: boolean;
|
|
374
|
+
|
|
375
|
+
/** Specify CSS-valid pixel offsets using bottom, left, and right. */
|
|
376
|
+
offset?: { bottom: string; left: string; right: string };
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* If `true`, the Subscription Bell will display an icon that there is 1 unread message.
|
|
380
|
+
* When hovering over the Subscription Bell, the user will see custom text set by message.prenotify.
|
|
381
|
+
*/
|
|
382
|
+
prenotify: boolean;
|
|
383
|
+
|
|
384
|
+
/** Either `bottom-left` or `bottom-right`. The Subscription Bell will be fixed at this location on your page. */
|
|
385
|
+
position?: 'bottom-left' | 'bottom-right';
|
|
386
|
+
|
|
387
|
+
/** Set `false` to hide the 'Powered by OneSignal' text in the Subscription Bell dialog popup. */
|
|
388
|
+
showCredit: boolean;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The Subscription Bell will initially appear at one of these sizes, and then shrink down to size `small` after the user subscribes.
|
|
392
|
+
*/
|
|
393
|
+
size?: 'small' | 'medium' | 'large';
|
|
394
|
+
|
|
395
|
+
/** Customize the Subscription Bell text. */
|
|
396
|
+
text: {
|
|
397
|
+
'dialog.blocked.message': string;
|
|
398
|
+
'dialog.blocked.title': string;
|
|
399
|
+
'dialog.main.button.subscribe': string;
|
|
400
|
+
'dialog.main.button.unsubscribe': string;
|
|
401
|
+
'dialog.main.title': string;
|
|
402
|
+
'message.action.resubscribed': string;
|
|
403
|
+
'message.action.subscribed': string;
|
|
404
|
+
'message.action.subscribing': string;
|
|
405
|
+
'message.action.unsubscribed': string;
|
|
406
|
+
'message.prenotify': string;
|
|
407
|
+
'tip.state.blocked': string;
|
|
408
|
+
'tip.state.subscribed': string;
|
|
409
|
+
'tip.state.unsubscribed': string;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
|
|
251
413
|
persistNotification?: boolean;
|
|
252
|
-
webhooks?:
|
|
414
|
+
webhooks?: {
|
|
415
|
+
/**
|
|
416
|
+
* Enable this setting only if your server has CORS enabled and supports non-simple CORS requests.
|
|
417
|
+
* If this setting is disabled, your webhook will not need CORS to receive data, but it will not receive the custom headers.
|
|
418
|
+
* The simplest option is to leave it disabled.
|
|
419
|
+
* @default false
|
|
420
|
+
*/
|
|
421
|
+
cors: boolean;
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* This event occurs after a notification is clicked.
|
|
425
|
+
* @example https://site.com/hook
|
|
426
|
+
*/
|
|
427
|
+
'notification.clicked'?: string;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* 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),
|
|
431
|
+
* 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.
|
|
432
|
+
* @example https://site.com/hook
|
|
433
|
+
*/
|
|
434
|
+
'notification.dismissed'?: string;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* This event occurs after a notification is displayed.
|
|
438
|
+
* @example https://site.com/hook
|
|
439
|
+
*/
|
|
440
|
+
'notification.willDisplay'?: string;
|
|
441
|
+
};
|
|
253
442
|
autoResubscribe?: boolean;
|
|
254
443
|
autoRegister?: boolean;
|
|
255
444
|
notificationClickHandlerMatch?: string;
|
|
256
445
|
notificationClickHandlerAction?: string;
|
|
446
|
+
path?: string;
|
|
257
447
|
serviceWorkerParam?: { scope: string };
|
|
258
448
|
serviceWorkerPath?: string;
|
|
449
|
+
serviceWorkerOverrideForTypical?: boolean;
|
|
259
450
|
serviceWorkerUpdaterPath?: string;
|
|
260
|
-
path?: string;
|
|
261
451
|
allowLocalhostAsSecureOrigin?: boolean;
|
|
262
452
|
[key: string]: any;
|
|
263
453
|
}
|
|
264
454
|
|
|
265
|
-
interface IOneSignalOneSignal {
|
|
455
|
+
export interface IOneSignalOneSignal {
|
|
266
456
|
Slidedown: IOneSignalSlidedown;
|
|
267
457
|
Notifications: IOneSignalNotifications;
|
|
268
458
|
Session: IOneSignalSession;
|
|
@@ -274,7 +464,7 @@ interface IOneSignalOneSignal {
|
|
|
274
464
|
setConsentGiven(consent: boolean): Promise<void>;
|
|
275
465
|
setConsentRequired(requiresConsent: boolean): Promise<void>;
|
|
276
466
|
}
|
|
277
|
-
interface IOneSignalNotifications {
|
|
467
|
+
export interface IOneSignalNotifications {
|
|
278
468
|
permissionNative: NotificationPermission;
|
|
279
469
|
permission: boolean;
|
|
280
470
|
setDefaultUrl(url: string): Promise<void>;
|
|
@@ -284,7 +474,7 @@ interface IOneSignalNotifications {
|
|
|
284
474
|
addEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void;
|
|
285
475
|
removeEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void;
|
|
286
476
|
}
|
|
287
|
-
interface IOneSignalSlidedown {
|
|
477
|
+
export interface IOneSignalSlidedown {
|
|
288
478
|
promptPush(options?: AutoPromptOptions): Promise<void>;
|
|
289
479
|
promptPushCategories(options?: AutoPromptOptions): Promise<void>;
|
|
290
480
|
promptSms(options?: AutoPromptOptions): Promise<void>;
|
|
@@ -293,14 +483,16 @@ interface IOneSignalSlidedown {
|
|
|
293
483
|
addEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
|
|
294
484
|
removeEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void;
|
|
295
485
|
}
|
|
296
|
-
interface IOneSignalDebug {
|
|
486
|
+
export interface IOneSignalDebug {
|
|
297
487
|
setLogLevel(logLevel: string): void;
|
|
298
488
|
}
|
|
299
|
-
interface IOneSignalSession {
|
|
489
|
+
export interface IOneSignalSession {
|
|
300
490
|
sendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void>;
|
|
301
491
|
sendUniqueOutcome(outcomeName: string): Promise<void>;
|
|
302
492
|
}
|
|
303
|
-
interface IOneSignalUser {
|
|
493
|
+
export interface IOneSignalUser {
|
|
494
|
+
onesignalId: string | undefined;
|
|
495
|
+
externalId: string | undefined;
|
|
304
496
|
PushSubscription: IOneSignalPushSubscription;
|
|
305
497
|
addAlias(label: string, id: string): void;
|
|
306
498
|
addAliases(aliases: { [key: string]: string }): void;
|
|
@@ -314,8 +506,13 @@ interface IOneSignalUser {
|
|
|
314
506
|
addTags(tags: { [key: string]: string }): void;
|
|
315
507
|
removeTag(key: string): void;
|
|
316
508
|
removeTags(keys: string[]): void;
|
|
509
|
+
getTags(): { [key: string]: string };
|
|
510
|
+
addEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void;
|
|
511
|
+
removeEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void;
|
|
512
|
+
setLanguage(language: string): void;
|
|
513
|
+
getLanguage(): string;
|
|
317
514
|
}
|
|
318
|
-
interface IOneSignalPushSubscription {
|
|
515
|
+
export interface IOneSignalPushSubscription {
|
|
319
516
|
id: string | null | undefined;
|
|
320
517
|
token: string | null | undefined;
|
|
321
518
|
optedIn: boolean | undefined;
|
|
@@ -324,17 +521,16 @@ interface IOneSignalPushSubscription {
|
|
|
324
521
|
addEventListener(event: 'change', listener: (change: SubscriptionChangeEvent) => void): void;
|
|
325
522
|
removeEventListener(event: 'change', listener: (change: SubscriptionChangeEvent) => void): void;
|
|
326
523
|
}
|
|
327
|
-
|
|
328
524
|
function oneSignalLogin(externalId: string, jwtToken?: string): Promise<void> {
|
|
329
525
|
return new Promise(function (resolve, reject) {
|
|
330
526
|
if (isOneSignalScriptFailed) {
|
|
331
|
-
reject();
|
|
527
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
528
|
+
return;
|
|
332
529
|
}
|
|
333
530
|
|
|
334
531
|
try {
|
|
335
532
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
336
|
-
OneSignal.login(externalId, jwtToken)
|
|
337
|
-
.then(value => resolve(value))
|
|
533
|
+
OneSignal.login(externalId, jwtToken).then(() => resolve())
|
|
338
534
|
.catch(error => reject(error));
|
|
339
535
|
});
|
|
340
536
|
} catch (error) {
|
|
@@ -342,17 +538,16 @@ function oneSignalLogin(externalId: string, jwtToken?: string): Promise<void> {
|
|
|
342
538
|
}
|
|
343
539
|
});
|
|
344
540
|
}
|
|
345
|
-
|
|
346
541
|
function oneSignalLogout(): Promise<void> {
|
|
347
542
|
return new Promise(function (resolve, reject) {
|
|
348
543
|
if (isOneSignalScriptFailed) {
|
|
349
|
-
reject();
|
|
544
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
545
|
+
return;
|
|
350
546
|
}
|
|
351
547
|
|
|
352
548
|
try {
|
|
353
549
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
354
|
-
OneSignal.logout()
|
|
355
|
-
.then(value => resolve(value))
|
|
550
|
+
OneSignal.logout().then(() => resolve())
|
|
356
551
|
.catch(error => reject(error));
|
|
357
552
|
});
|
|
358
553
|
} catch (error) {
|
|
@@ -360,17 +555,16 @@ function oneSignalLogout(): Promise<void> {
|
|
|
360
555
|
}
|
|
361
556
|
});
|
|
362
557
|
}
|
|
363
|
-
|
|
364
558
|
function oneSignalSetConsentGiven(consent: boolean): Promise<void> {
|
|
365
559
|
return new Promise(function (resolve, reject) {
|
|
366
560
|
if (isOneSignalScriptFailed) {
|
|
367
|
-
reject();
|
|
561
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
562
|
+
return;
|
|
368
563
|
}
|
|
369
564
|
|
|
370
565
|
try {
|
|
371
566
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
372
|
-
OneSignal.setConsentGiven(consent)
|
|
373
|
-
.then(value => resolve(value))
|
|
567
|
+
OneSignal.setConsentGiven(consent).then(() => resolve())
|
|
374
568
|
.catch(error => reject(error));
|
|
375
569
|
});
|
|
376
570
|
} catch (error) {
|
|
@@ -378,17 +572,16 @@ function oneSignalSetConsentGiven(consent: boolean): Promise<void> {
|
|
|
378
572
|
}
|
|
379
573
|
});
|
|
380
574
|
}
|
|
381
|
-
|
|
382
575
|
function oneSignalSetConsentRequired(requiresConsent: boolean): Promise<void> {
|
|
383
576
|
return new Promise(function (resolve, reject) {
|
|
384
577
|
if (isOneSignalScriptFailed) {
|
|
385
|
-
reject();
|
|
578
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
579
|
+
return;
|
|
386
580
|
}
|
|
387
581
|
|
|
388
582
|
try {
|
|
389
583
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
390
|
-
OneSignal.setConsentRequired(requiresConsent)
|
|
391
|
-
.then(value => resolve(value))
|
|
584
|
+
OneSignal.setConsentRequired(requiresConsent).then(() => resolve())
|
|
392
585
|
.catch(error => reject(error));
|
|
393
586
|
});
|
|
394
587
|
} catch (error) {
|
|
@@ -396,17 +589,16 @@ function oneSignalSetConsentRequired(requiresConsent: boolean): Promise<void> {
|
|
|
396
589
|
}
|
|
397
590
|
});
|
|
398
591
|
}
|
|
399
|
-
|
|
400
592
|
function slidedownPromptPush(options?: AutoPromptOptions): Promise<void> {
|
|
401
593
|
return new Promise(function (resolve, reject) {
|
|
402
594
|
if (isOneSignalScriptFailed) {
|
|
403
|
-
reject();
|
|
595
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
596
|
+
return;
|
|
404
597
|
}
|
|
405
598
|
|
|
406
599
|
try {
|
|
407
600
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
408
|
-
OneSignal.Slidedown.promptPush(options)
|
|
409
|
-
.then(value => resolve(value))
|
|
601
|
+
OneSignal.Slidedown.promptPush(options).then(() => resolve())
|
|
410
602
|
.catch(error => reject(error));
|
|
411
603
|
});
|
|
412
604
|
} catch (error) {
|
|
@@ -414,17 +606,16 @@ function slidedownPromptPush(options?: AutoPromptOptions): Promise<void> {
|
|
|
414
606
|
}
|
|
415
607
|
});
|
|
416
608
|
}
|
|
417
|
-
|
|
418
609
|
function slidedownPromptPushCategories(options?: AutoPromptOptions): Promise<void> {
|
|
419
610
|
return new Promise(function (resolve, reject) {
|
|
420
611
|
if (isOneSignalScriptFailed) {
|
|
421
|
-
reject();
|
|
612
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
613
|
+
return;
|
|
422
614
|
}
|
|
423
615
|
|
|
424
616
|
try {
|
|
425
617
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
426
|
-
OneSignal.Slidedown.promptPushCategories(options)
|
|
427
|
-
.then(value => resolve(value))
|
|
618
|
+
OneSignal.Slidedown.promptPushCategories(options).then(() => resolve())
|
|
428
619
|
.catch(error => reject(error));
|
|
429
620
|
});
|
|
430
621
|
} catch (error) {
|
|
@@ -432,17 +623,16 @@ function slidedownPromptPushCategories(options?: AutoPromptOptions): Promise<voi
|
|
|
432
623
|
}
|
|
433
624
|
});
|
|
434
625
|
}
|
|
435
|
-
|
|
436
626
|
function slidedownPromptSms(options?: AutoPromptOptions): Promise<void> {
|
|
437
627
|
return new Promise(function (resolve, reject) {
|
|
438
628
|
if (isOneSignalScriptFailed) {
|
|
439
|
-
reject();
|
|
629
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
630
|
+
return;
|
|
440
631
|
}
|
|
441
632
|
|
|
442
633
|
try {
|
|
443
634
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
444
|
-
OneSignal.Slidedown.promptSms(options)
|
|
445
|
-
.then(value => resolve(value))
|
|
635
|
+
OneSignal.Slidedown.promptSms(options).then(() => resolve())
|
|
446
636
|
.catch(error => reject(error));
|
|
447
637
|
});
|
|
448
638
|
} catch (error) {
|
|
@@ -450,17 +640,16 @@ function slidedownPromptSms(options?: AutoPromptOptions): Promise<void> {
|
|
|
450
640
|
}
|
|
451
641
|
});
|
|
452
642
|
}
|
|
453
|
-
|
|
454
643
|
function slidedownPromptEmail(options?: AutoPromptOptions): Promise<void> {
|
|
455
644
|
return new Promise(function (resolve, reject) {
|
|
456
645
|
if (isOneSignalScriptFailed) {
|
|
457
|
-
reject();
|
|
646
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
647
|
+
return;
|
|
458
648
|
}
|
|
459
649
|
|
|
460
650
|
try {
|
|
461
651
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
462
|
-
OneSignal.Slidedown.promptEmail(options)
|
|
463
|
-
.then(value => resolve(value))
|
|
652
|
+
OneSignal.Slidedown.promptEmail(options).then(() => resolve())
|
|
464
653
|
.catch(error => reject(error));
|
|
465
654
|
});
|
|
466
655
|
} catch (error) {
|
|
@@ -468,17 +657,16 @@ function slidedownPromptEmail(options?: AutoPromptOptions): Promise<void> {
|
|
|
468
657
|
}
|
|
469
658
|
});
|
|
470
659
|
}
|
|
471
|
-
|
|
472
660
|
function slidedownPromptSmsAndEmail(options?: AutoPromptOptions): Promise<void> {
|
|
473
661
|
return new Promise(function (resolve, reject) {
|
|
474
662
|
if (isOneSignalScriptFailed) {
|
|
475
|
-
reject();
|
|
663
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
664
|
+
return;
|
|
476
665
|
}
|
|
477
666
|
|
|
478
667
|
try {
|
|
479
668
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
480
|
-
OneSignal.Slidedown.promptSmsAndEmail(options)
|
|
481
|
-
.then(value => resolve(value))
|
|
669
|
+
OneSignal.Slidedown.promptSmsAndEmail(options).then(() => resolve())
|
|
482
670
|
.catch(error => reject(error));
|
|
483
671
|
});
|
|
484
672
|
} catch (error) {
|
|
@@ -486,29 +674,30 @@ function slidedownPromptSmsAndEmail(options?: AutoPromptOptions): Promise<void>
|
|
|
486
674
|
}
|
|
487
675
|
});
|
|
488
676
|
}
|
|
489
|
-
|
|
490
677
|
function slidedownAddEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void {
|
|
678
|
+
|
|
491
679
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
492
|
-
OneSignal.Slidedown.addEventListener(event, listener)
|
|
680
|
+
OneSignal.Slidedown.addEventListener(event, listener);
|
|
493
681
|
});
|
|
682
|
+
|
|
494
683
|
}
|
|
495
|
-
|
|
496
684
|
function slidedownRemoveEventListener(event: SlidedownEventName, listener: (wasShown: boolean) => void): void {
|
|
685
|
+
|
|
497
686
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
498
|
-
OneSignal.Slidedown.removeEventListener(event, listener)
|
|
687
|
+
OneSignal.Slidedown.removeEventListener(event, listener);
|
|
499
688
|
});
|
|
689
|
+
|
|
500
690
|
}
|
|
501
|
-
|
|
502
691
|
function notificationsSetDefaultUrl(url: string): Promise<void> {
|
|
503
692
|
return new Promise(function (resolve, reject) {
|
|
504
693
|
if (isOneSignalScriptFailed) {
|
|
505
|
-
reject();
|
|
694
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
695
|
+
return;
|
|
506
696
|
}
|
|
507
697
|
|
|
508
698
|
try {
|
|
509
699
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
510
|
-
OneSignal.Notifications.setDefaultUrl(url)
|
|
511
|
-
.then(value => resolve(value))
|
|
700
|
+
OneSignal.Notifications.setDefaultUrl(url).then(() => resolve())
|
|
512
701
|
.catch(error => reject(error));
|
|
513
702
|
});
|
|
514
703
|
} catch (error) {
|
|
@@ -516,17 +705,16 @@ function notificationsSetDefaultUrl(url: string): Promise<void> {
|
|
|
516
705
|
}
|
|
517
706
|
});
|
|
518
707
|
}
|
|
519
|
-
|
|
520
708
|
function notificationsSetDefaultTitle(title: string): Promise<void> {
|
|
521
709
|
return new Promise(function (resolve, reject) {
|
|
522
710
|
if (isOneSignalScriptFailed) {
|
|
523
|
-
reject();
|
|
711
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
712
|
+
return;
|
|
524
713
|
}
|
|
525
714
|
|
|
526
715
|
try {
|
|
527
716
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
528
|
-
OneSignal.Notifications.setDefaultTitle(title)
|
|
529
|
-
.then(value => resolve(value))
|
|
717
|
+
OneSignal.Notifications.setDefaultTitle(title).then(() => resolve())
|
|
530
718
|
.catch(error => reject(error));
|
|
531
719
|
});
|
|
532
720
|
} catch (error) {
|
|
@@ -534,17 +722,16 @@ function notificationsSetDefaultTitle(title: string): Promise<void> {
|
|
|
534
722
|
}
|
|
535
723
|
});
|
|
536
724
|
}
|
|
537
|
-
|
|
538
725
|
function notificationsRequestPermission(): Promise<void> {
|
|
539
726
|
return new Promise(function (resolve, reject) {
|
|
540
727
|
if (isOneSignalScriptFailed) {
|
|
541
|
-
reject();
|
|
728
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
729
|
+
return;
|
|
542
730
|
}
|
|
543
731
|
|
|
544
732
|
try {
|
|
545
733
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
546
|
-
OneSignal.Notifications.requestPermission()
|
|
547
|
-
.then(value => resolve(value))
|
|
734
|
+
OneSignal.Notifications.requestPermission().then(() => resolve())
|
|
548
735
|
.catch(error => reject(error));
|
|
549
736
|
});
|
|
550
737
|
} catch (error) {
|
|
@@ -552,29 +739,30 @@ function notificationsRequestPermission(): Promise<void> {
|
|
|
552
739
|
}
|
|
553
740
|
});
|
|
554
741
|
}
|
|
555
|
-
|
|
556
742
|
function notificationsAddEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void {
|
|
743
|
+
|
|
557
744
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
558
|
-
OneSignal.Notifications.addEventListener(event, listener)
|
|
745
|
+
OneSignal.Notifications.addEventListener(event, listener);
|
|
559
746
|
});
|
|
747
|
+
|
|
560
748
|
}
|
|
561
|
-
|
|
562
749
|
function notificationsRemoveEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void {
|
|
750
|
+
|
|
563
751
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
564
|
-
OneSignal.Notifications.removeEventListener(event, listener)
|
|
752
|
+
OneSignal.Notifications.removeEventListener(event, listener);
|
|
565
753
|
});
|
|
754
|
+
|
|
566
755
|
}
|
|
567
|
-
|
|
568
756
|
function sessionSendOutcome(outcomeName: string, outcomeWeight?: number): Promise<void> {
|
|
569
757
|
return new Promise(function (resolve, reject) {
|
|
570
758
|
if (isOneSignalScriptFailed) {
|
|
571
|
-
reject();
|
|
759
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
760
|
+
return;
|
|
572
761
|
}
|
|
573
762
|
|
|
574
763
|
try {
|
|
575
764
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
576
|
-
OneSignal.Session.sendOutcome(outcomeName, outcomeWeight)
|
|
577
|
-
.then(value => resolve(value))
|
|
765
|
+
OneSignal.Session.sendOutcome(outcomeName, outcomeWeight).then(() => resolve())
|
|
578
766
|
.catch(error => reject(error));
|
|
579
767
|
});
|
|
580
768
|
} catch (error) {
|
|
@@ -582,17 +770,16 @@ function sessionSendOutcome(outcomeName: string, outcomeWeight?: number): Promis
|
|
|
582
770
|
}
|
|
583
771
|
});
|
|
584
772
|
}
|
|
585
|
-
|
|
586
773
|
function sessionSendUniqueOutcome(outcomeName: string): Promise<void> {
|
|
587
774
|
return new Promise(function (resolve, reject) {
|
|
588
775
|
if (isOneSignalScriptFailed) {
|
|
589
|
-
reject();
|
|
776
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
777
|
+
return;
|
|
590
778
|
}
|
|
591
779
|
|
|
592
780
|
try {
|
|
593
781
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
594
|
-
OneSignal.Session.sendUniqueOutcome(outcomeName)
|
|
595
|
-
.then(value => resolve(value))
|
|
782
|
+
OneSignal.Session.sendUniqueOutcome(outcomeName).then(() => resolve())
|
|
596
783
|
.catch(error => reject(error));
|
|
597
784
|
});
|
|
598
785
|
} catch (error) {
|
|
@@ -600,89 +787,135 @@ function sessionSendUniqueOutcome(outcomeName: string): Promise<void> {
|
|
|
600
787
|
}
|
|
601
788
|
});
|
|
602
789
|
}
|
|
603
|
-
|
|
604
790
|
function userAddAlias(label: string, id: string): void {
|
|
791
|
+
|
|
605
792
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
606
|
-
OneSignal.User.addAlias(label, id)
|
|
793
|
+
OneSignal.User.addAlias(label, id);
|
|
607
794
|
});
|
|
795
|
+
|
|
608
796
|
}
|
|
609
|
-
|
|
610
797
|
function userAddAliases(aliases: { [key: string]: string }): void {
|
|
798
|
+
|
|
611
799
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
612
|
-
OneSignal.User.addAliases(aliases)
|
|
800
|
+
OneSignal.User.addAliases(aliases);
|
|
613
801
|
});
|
|
802
|
+
|
|
614
803
|
}
|
|
615
|
-
|
|
616
804
|
function userRemoveAlias(label: string): void {
|
|
805
|
+
|
|
617
806
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
618
|
-
OneSignal.User.removeAlias(label)
|
|
807
|
+
OneSignal.User.removeAlias(label);
|
|
619
808
|
});
|
|
809
|
+
|
|
620
810
|
}
|
|
621
|
-
|
|
622
811
|
function userRemoveAliases(labels: string[]): void {
|
|
812
|
+
|
|
623
813
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
624
|
-
OneSignal.User.removeAliases(labels)
|
|
814
|
+
OneSignal.User.removeAliases(labels);
|
|
625
815
|
});
|
|
816
|
+
|
|
626
817
|
}
|
|
627
|
-
|
|
628
818
|
function userAddEmail(email: string): void {
|
|
819
|
+
|
|
629
820
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
630
|
-
OneSignal.User.addEmail(email)
|
|
821
|
+
OneSignal.User.addEmail(email);
|
|
631
822
|
});
|
|
823
|
+
|
|
632
824
|
}
|
|
633
|
-
|
|
634
825
|
function userRemoveEmail(email: string): void {
|
|
826
|
+
|
|
635
827
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
636
|
-
OneSignal.User.removeEmail(email)
|
|
828
|
+
OneSignal.User.removeEmail(email);
|
|
637
829
|
});
|
|
830
|
+
|
|
638
831
|
}
|
|
639
|
-
|
|
640
832
|
function userAddSms(smsNumber: string): void {
|
|
833
|
+
|
|
641
834
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
642
|
-
OneSignal.User.addSms(smsNumber)
|
|
835
|
+
OneSignal.User.addSms(smsNumber);
|
|
643
836
|
});
|
|
837
|
+
|
|
644
838
|
}
|
|
645
|
-
|
|
646
839
|
function userRemoveSms(smsNumber: string): void {
|
|
840
|
+
|
|
647
841
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
648
|
-
OneSignal.User.removeSms(smsNumber)
|
|
842
|
+
OneSignal.User.removeSms(smsNumber);
|
|
649
843
|
});
|
|
844
|
+
|
|
650
845
|
}
|
|
651
|
-
|
|
652
846
|
function userAddTag(key: string, value: string): void {
|
|
847
|
+
|
|
653
848
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
654
|
-
OneSignal.User.addTag(key, value)
|
|
849
|
+
OneSignal.User.addTag(key, value);
|
|
655
850
|
});
|
|
851
|
+
|
|
656
852
|
}
|
|
657
|
-
|
|
658
853
|
function userAddTags(tags: { [key: string]: string }): void {
|
|
854
|
+
|
|
659
855
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
660
|
-
OneSignal.User.addTags(tags)
|
|
856
|
+
OneSignal.User.addTags(tags);
|
|
661
857
|
});
|
|
858
|
+
|
|
662
859
|
}
|
|
663
|
-
|
|
664
860
|
function userRemoveTag(key: string): void {
|
|
861
|
+
|
|
665
862
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
666
|
-
OneSignal.User.removeTag(key)
|
|
863
|
+
OneSignal.User.removeTag(key);
|
|
667
864
|
});
|
|
865
|
+
|
|
668
866
|
}
|
|
669
|
-
|
|
670
867
|
function userRemoveTags(keys: string[]): void {
|
|
868
|
+
|
|
671
869
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
672
|
-
OneSignal.User.removeTags(keys)
|
|
870
|
+
OneSignal.User.removeTags(keys);
|
|
673
871
|
});
|
|
872
|
+
|
|
873
|
+
}
|
|
874
|
+
function userGetTags(): { [key: string]: string } {
|
|
875
|
+
let retVal: { [key: string]: string };
|
|
876
|
+
window.OneSignalDeferred?.push((OneSignal) => {
|
|
877
|
+
retVal = OneSignal.User.getTags();
|
|
878
|
+
});
|
|
879
|
+
return retVal;
|
|
880
|
+
}
|
|
881
|
+
function userAddEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void {
|
|
882
|
+
|
|
883
|
+
window.OneSignalDeferred?.push((OneSignal) => {
|
|
884
|
+
OneSignal.User.addEventListener(event, listener);
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
}
|
|
888
|
+
function userRemoveEventListener(event: 'change', listener: (change: UserChangeEvent) => void): void {
|
|
889
|
+
|
|
890
|
+
window.OneSignalDeferred?.push((OneSignal) => {
|
|
891
|
+
OneSignal.User.removeEventListener(event, listener);
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
}
|
|
895
|
+
function userSetLanguage(language: string): void {
|
|
896
|
+
|
|
897
|
+
window.OneSignalDeferred?.push((OneSignal) => {
|
|
898
|
+
OneSignal.User.setLanguage(language);
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
}
|
|
902
|
+
function userGetLanguage(): string {
|
|
903
|
+
let retVal: string;
|
|
904
|
+
window.OneSignalDeferred?.push((OneSignal) => {
|
|
905
|
+
retVal = OneSignal.User.getLanguage();
|
|
906
|
+
});
|
|
907
|
+
return retVal;
|
|
674
908
|
}
|
|
675
|
-
|
|
676
909
|
function pushSubscriptionOptIn(): Promise<void> {
|
|
677
910
|
return new Promise(function (resolve, reject) {
|
|
678
911
|
if (isOneSignalScriptFailed) {
|
|
679
|
-
reject();
|
|
912
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
913
|
+
return;
|
|
680
914
|
}
|
|
681
915
|
|
|
682
916
|
try {
|
|
683
917
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
684
|
-
OneSignal.User.PushSubscription.optIn()
|
|
685
|
-
.then(value => resolve(value))
|
|
918
|
+
OneSignal.User.PushSubscription.optIn().then(() => resolve())
|
|
686
919
|
.catch(error => reject(error));
|
|
687
920
|
});
|
|
688
921
|
} catch (error) {
|
|
@@ -690,17 +923,16 @@ function pushSubscriptionOptIn(): Promise<void> {
|
|
|
690
923
|
}
|
|
691
924
|
});
|
|
692
925
|
}
|
|
693
|
-
|
|
694
926
|
function pushSubscriptionOptOut(): Promise<void> {
|
|
695
927
|
return new Promise(function (resolve, reject) {
|
|
696
928
|
if (isOneSignalScriptFailed) {
|
|
697
|
-
reject();
|
|
929
|
+
reject(new Error('OneSignal script failed to load.'));
|
|
930
|
+
return;
|
|
698
931
|
}
|
|
699
932
|
|
|
700
933
|
try {
|
|
701
934
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
702
|
-
OneSignal.User.PushSubscription.optOut()
|
|
703
|
-
.then(value => resolve(value))
|
|
935
|
+
OneSignal.User.PushSubscription.optOut().then(() => resolve())
|
|
704
936
|
.catch(error => reject(error));
|
|
705
937
|
});
|
|
706
938
|
} catch (error) {
|
|
@@ -708,28 +940,31 @@ function pushSubscriptionOptOut(): Promise<void> {
|
|
|
708
940
|
}
|
|
709
941
|
});
|
|
710
942
|
}
|
|
711
|
-
|
|
712
943
|
function pushSubscriptionAddEventListener(event: 'change', listener: (change: SubscriptionChangeEvent) => void): void {
|
|
944
|
+
|
|
713
945
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
714
|
-
OneSignal.User.PushSubscription.addEventListener(event, listener)
|
|
946
|
+
OneSignal.User.PushSubscription.addEventListener(event, listener);
|
|
715
947
|
});
|
|
948
|
+
|
|
716
949
|
}
|
|
717
|
-
|
|
718
950
|
function pushSubscriptionRemoveEventListener(event: 'change', listener: (change: SubscriptionChangeEvent) => void): void {
|
|
951
|
+
|
|
719
952
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
720
|
-
OneSignal.User.PushSubscription.removeEventListener(event, listener)
|
|
953
|
+
OneSignal.User.PushSubscription.removeEventListener(event, listener);
|
|
721
954
|
});
|
|
955
|
+
|
|
722
956
|
}
|
|
723
|
-
|
|
724
957
|
function debugSetLogLevel(logLevel: string): void {
|
|
958
|
+
|
|
725
959
|
window.OneSignalDeferred?.push((OneSignal) => {
|
|
726
|
-
OneSignal.Debug.setLogLevel(logLevel)
|
|
960
|
+
OneSignal.Debug.setLogLevel(logLevel);
|
|
727
961
|
});
|
|
962
|
+
|
|
728
963
|
}
|
|
729
964
|
const PushSubscriptionNamespace: IOneSignalPushSubscription = {
|
|
730
|
-
get id(): string | null | undefined { return window.OneSignal?.User?.PushSubscription?.id },
|
|
731
|
-
get token(): string | null | undefined { return window.OneSignal?.User?.PushSubscription?.token },
|
|
732
|
-
get optedIn(): boolean | undefined { return window.OneSignal?.User?.PushSubscription?.optedIn },
|
|
965
|
+
get id(): string | null | undefined { return window.OneSignal?.User?.PushSubscription?.id; },
|
|
966
|
+
get token(): string | null | undefined { return window.OneSignal?.User?.PushSubscription?.token; },
|
|
967
|
+
get optedIn(): boolean | undefined { return window.OneSignal?.User?.PushSubscription?.optedIn; },
|
|
733
968
|
optIn: pushSubscriptionOptIn,
|
|
734
969
|
optOut: pushSubscriptionOptOut,
|
|
735
970
|
addEventListener: pushSubscriptionAddEventListener,
|
|
@@ -737,6 +972,8 @@ const PushSubscriptionNamespace: IOneSignalPushSubscription = {
|
|
|
737
972
|
};
|
|
738
973
|
|
|
739
974
|
const UserNamespace: IOneSignalUser = {
|
|
975
|
+
get onesignalId(): string | undefined { return window.OneSignal?.User?.onesignalId; },
|
|
976
|
+
get externalId(): string | undefined { return window.OneSignal?.User?.externalId; },
|
|
740
977
|
addAlias: userAddAlias,
|
|
741
978
|
addAliases: userAddAliases,
|
|
742
979
|
removeAlias: userRemoveAlias,
|
|
@@ -749,6 +986,11 @@ const UserNamespace: IOneSignalUser = {
|
|
|
749
986
|
addTags: userAddTags,
|
|
750
987
|
removeTag: userRemoveTag,
|
|
751
988
|
removeTags: userRemoveTags,
|
|
989
|
+
getTags: userGetTags,
|
|
990
|
+
addEventListener: userAddEventListener,
|
|
991
|
+
removeEventListener: userRemoveEventListener,
|
|
992
|
+
setLanguage: userSetLanguage,
|
|
993
|
+
getLanguage: userGetLanguage,
|
|
752
994
|
PushSubscription: PushSubscriptionNamespace,
|
|
753
995
|
};
|
|
754
996
|
|