@kolektor/nucleus-notifications 0.0.9-pre.5707 → 0.0.10-pre.6137
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/esm2020/lib/nucleus-notifications.module.mjs +5 -5
- package/esm2020/lib/nucleus-notifications.service.mjs +3 -3
- package/fesm2015/kolektor-nucleus-notifications.mjs +8 -7
- package/fesm2015/kolektor-nucleus-notifications.mjs.map +1 -1
- package/fesm2020/kolektor-nucleus-notifications.mjs +8 -7
- package/fesm2020/kolektor-nucleus-notifications.mjs.map +1 -1
- package/{kolektor-nucleus-notifications.d.ts → index.d.ts} +0 -0
- package/package.json +7 -7
|
@@ -11,10 +11,10 @@ export class NucleusNotificationsModule {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
NucleusNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
15
|
-
NucleusNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
16
|
-
NucleusNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
17
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
14
|
+
NucleusNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
15
|
+
NucleusNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule });
|
|
16
|
+
NucleusNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule });
|
|
17
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule, decorators: [{
|
|
18
18
|
type: NgModule,
|
|
19
19
|
args: [{
|
|
20
20
|
declarations: [],
|
|
@@ -22,4 +22,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
22
22
|
exports: []
|
|
23
23
|
}]
|
|
24
24
|
}] });
|
|
25
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnVjbGV1cy1ub3RpZmljYXRpb25zLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL251Y2xldXMtbm90aWZpY2F0aW9ucy9zcmMvbGliL251Y2xldXMtbm90aWZpY2F0aW9ucy5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBdUIsTUFBTSxlQUFlLENBQUM7QUFDOUQsT0FBTyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sVUFBVSxDQUFDOztBQVF0RCxNQUFNLE9BQU8sMEJBQTBCO0lBRXJDLE1BQU0sQ0FBQyxPQUFPLENBQUMsTUFBa0M7UUFDL0MsT0FBTztZQUNMLFFBQVEsRUFBRSwwQkFBMEI7WUFDcEMsU0FBUyxFQUFFO2dCQUNULEVBQUUsT0FBTyxFQUFFLDBCQUEwQixFQUFFLFFBQVEsRUFBRSxNQUFNLEVBQUU7YUFDMUQ7U0FDRixDQUFDO0lBQ0osQ0FBQzs7dUhBVFUsMEJBQTBCO3dIQUExQiwwQkFBMEI7d0hBQTFCLDBCQUEwQjsyRkFBMUIsMEJBQTBCO2tCQU50QyxRQUFRO21CQUFDO29CQUNSLFlBQVksRUFBRSxFQUFFO29CQUNoQixPQUFPLEVBQUUsRUFDUjtvQkFDRCxPQUFPLEVBQUUsRUFBRTtpQkFDWiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IE5nTW9kdWxlLCBNb2R1bGVXaXRoUHJvdmlkZXJzIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XHJcbmltcG9ydCB7IE51Y2xldXNOb3RpZmljYXRpb25zQ29uZmlnIH0gZnJvbSAnLi9tb2RlbHMnO1xyXG5cclxuQE5nTW9kdWxlKHtcclxuICBkZWNsYXJhdGlvbnM6IFtdLFxyXG4gIGltcG9ydHM6IFtcclxuICBdLFxyXG4gIGV4cG9ydHM6IFtdXHJcbn0pXHJcbmV4cG9ydCBjbGFzcyBOdWNsZXVzTm90aWZpY2F0aW9uc01vZHVsZSB7XHJcblxyXG4gIHN0YXRpYyBmb3JSb290KGNvbmZpZzogTnVjbGV1c05vdGlmaWNhdGlvbnNDb25maWcpOiBNb2R1bGVXaXRoUHJvdmlkZXJzPE51Y2xldXNOb3RpZmljYXRpb25zTW9kdWxlPiB7XHJcbiAgICByZXR1cm4ge1xyXG4gICAgICBuZ01vZHVsZTogTnVjbGV1c05vdGlmaWNhdGlvbnNNb2R1bGUsXHJcbiAgICAgIHByb3ZpZGVyczogW1xyXG4gICAgICAgIHsgcHJvdmlkZTogTnVjbGV1c05vdGlmaWNhdGlvbnNDb25maWcsIHVzZVZhbHVlOiBjb25maWcgfVxyXG4gICAgICBdXHJcbiAgICB9O1xyXG4gIH1cclxufVxyXG4iXX0=
|
|
@@ -345,9 +345,9 @@ export class NucleusNotificationsService {
|
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
-
NucleusNotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
349
|
-
NucleusNotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
350
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
348
|
+
NucleusNotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, deps: [{ token: i1.HttpClient }, { token: i2.SwPush }, { token: i3.NucleusAppService }, { token: i4.NucleusNotificationsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
349
|
+
NucleusNotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, providedIn: 'root' });
|
|
350
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, decorators: [{
|
|
351
351
|
type: Injectable,
|
|
352
352
|
args: [{
|
|
353
353
|
providedIn: 'root'
|
|
@@ -369,9 +369,9 @@ class NucleusNotificationsService {
|
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
NucleusNotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
373
|
-
NucleusNotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
374
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
372
|
+
NucleusNotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, deps: [{ token: i1.HttpClient }, { token: i2.SwPush }, { token: i3.NucleusAppService }, { token: NucleusNotificationsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
373
|
+
NucleusNotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, providedIn: 'root' });
|
|
374
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, decorators: [{
|
|
375
375
|
type: Injectable,
|
|
376
376
|
args: [{
|
|
377
377
|
providedIn: 'root'
|
|
@@ -388,10 +388,10 @@ class NucleusNotificationsModule {
|
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
NucleusNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
392
|
-
NucleusNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
393
|
-
NucleusNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
394
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
391
|
+
NucleusNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
392
|
+
NucleusNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule });
|
|
393
|
+
NucleusNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule });
|
|
394
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule, decorators: [{
|
|
395
395
|
type: NgModule,
|
|
396
396
|
args: [{
|
|
397
397
|
declarations: [],
|
|
@@ -409,3 +409,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
409
409
|
*/
|
|
410
410
|
|
|
411
411
|
export { Identity, Notification, NotificationClick, NotificationData, NucleusNotificationsConfig, NucleusNotificationsModule, NucleusNotificationsService, PayloadData, Recipient, Registration, RegistrationResult, UserChannelConfig, WebKey };
|
|
412
|
+
//# sourceMappingURL=kolektor-nucleus-notifications.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kolektor-nucleus-notifications.mjs","sources":["../../../projects/nucleus-notifications/src/lib/models.ts","../../../projects/nucleus-notifications/src/lib/nucleus-notifications.service.ts","../../../projects/nucleus-notifications/src/lib/nucleus-notifications.module.ts","../../../projects/nucleus-notifications/src/public-api.ts","../../../projects/nucleus-notifications/src/kolektor-nucleus-notifications.ts"],"sourcesContent":["export class Notification {\r\n public id: string;\r\n public sender: Identity;\r\n public data: NotificationData;\r\n public isRead: boolean;\r\n public dateCreated: Date;\r\n public expirationDate: Date;\r\n}\r\n\r\nexport class Identity {\r\n public subject: string;\r\n public name: string;\r\n public pictureUrl: string;\r\n}\r\n\r\nexport class Recipient {\r\n public attributeName: string;\r\n public directoryName: string;\r\n public attributeValue: string;\r\n}\r\n\r\nexport class NotificationData {\r\n title: string;\r\n message: string;\r\n htmlMessage: string;\r\n preventDismissal: boolean;\r\n deepLink: string;\r\n}\r\n\r\nexport class WebKey {\r\n publicKey: string;\r\n}\r\n\r\nexport class Registration {\r\n id: string;\r\n token: string;\r\n platform: PlatformValue;\r\n}\r\n\r\nexport class RegistrationResult {\r\n id: string;\r\n}\r\n\r\nexport class PayloadData {\r\n notificationId: string;\r\n eventType: NotificationEventType;\r\n}\r\n\r\nexport class NucleusNotificationsConfig {\r\n serverApiUrl: string;\r\n}\r\n\r\nexport class NotificationClick {\r\n id: string;\r\n type: NotificationType;\r\n routerLink?: string;\r\n}\r\n\r\nexport type NotificationEventType = 'new' | 'updated' | 'deleted' | 'deletedAll' | 'updatedAll' | 'newSilent';\r\n\r\nexport type PlatformValue = 'ios' | 'android' | 'web' | 'none';\r\n\r\nexport type NotificationType = 'default' | 'deeplink';\r\n\r\nexport interface ChannelId {\r\n senderId: string;\r\n channelId: string;\r\n}\r\n\r\nexport class UserChannelConfig {\r\n channelId: string;\r\n displayName: string;\r\n isSubscribed: boolean;\r\n subscriptionType: ChannelSubscriptionType;\r\n methods: NotifyMethod[];\r\n allowedMethods: NotifyMethod[];\r\n}\r\n\r\nexport type ChannelSubscriptionType = 'invariant' | 'optIn' | 'optOut';\r\n\r\nexport type NotifyMethod = 'push' | 'email' | 'sms';\r\n","import { HttpClient } from '@angular/common/http';\r\nimport { Injectable } from '@angular/core';\r\nimport { SwPush } from '@angular/service-worker';\r\nimport { PushNotifications, PushNotificationSchema } from '@capacitor/push-notifications';\r\nimport { NucleusAppService } from '@kolektor/nucleus-common';\r\nimport { Observable, of, Subject } from 'rxjs';\r\nimport {\r\n ChannelId,\r\n Notification,\r\n NotificationClick,\r\n NotificationEventType,\r\n NotificationType,\r\n NucleusNotificationsConfig,\r\n PayloadData,\r\n PlatformValue,\r\n Registration,\r\n RegistrationResult,\r\n UserChannelConfig,\r\n WebKey\r\n} from './models';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class NucleusNotificationsService {\r\n\r\n constructor(\r\n private http: HttpClient,\r\n private swPush: SwPush,\r\n private appService: NucleusAppService,\r\n config: NucleusNotificationsConfig\r\n ) {\r\n let url = config.serverApiUrl;\r\n if (!url.endsWith('/')) {\r\n url += '/';\r\n }\r\n this.apiUrl = url;\r\n }\r\n\r\n private apiUrl = null;\r\n private readonly registrationStorageKey = 'NucleusNotificationsRegistrationId';\r\n private readonly notificationsStorageKey = 'NucleusNotificationsLocalCache';\r\n private _platform: PlatformValue;\r\n private _isInitialized = false;\r\n private _newNotifications = new Subject<Notification>();\r\n private _clicksSubject = new Subject<NotificationClick>();\r\n private _stateChangesSubject = new Subject<void>();\r\n\r\n public notifications: Notification[] = [];\r\n\r\n public get unreadCount() {\r\n return this.notifications.filter(x => !x.isRead).length;\r\n }\r\n\r\n public get newNotifications() {\r\n return this._newNotifications.asObservable();\r\n }\r\n\r\n public get clicks() {\r\n return this._clicksSubject.asObservable();\r\n }\r\n public get stateChanges() {\r\n return this._stateChangesSubject.asObservable();\r\n }\r\n\r\n public get isInitialized() {\r\n return this._isInitialized;\r\n }\r\n\r\n public async initialize() {\r\n // make sure app service has finished initializing\r\n await this.appService.init();\r\n\r\n this.loadFromStorage();\r\n\r\n if (this.appService.isNative) {\r\n this._platform = this.appService.deviceInfo.platform as PlatformValue;\r\n await this.registerCapacitorEvents();\r\n } else if (this.swPush.isEnabled) {\r\n this._platform = 'web';\r\n this.registerWebPushEvents();\r\n } else {\r\n console.warn('Nucleus.Notifications: There is no push capability, timer will be used to update notifications');\r\n setInterval(() => {\r\n console.log('Updating notifications...');\r\n this.refresh(true);\r\n }, 5 * 60 * 1000);\r\n }\r\n this._isInitialized = true;\r\n this.refresh();\r\n }\r\n\r\n public register(): Promise<any> {\r\n return new Promise((_resolve, _reject) => {\r\n this.getRegistrationInfo().then((info) => {\r\n this.http.post<RegistrationResult>(this.apiUrl + 'registration', info).subscribe((regResult) => {\r\n window.localStorage.setItem(this.registrationStorageKey, regResult.id);\r\n _resolve(null);\r\n }, error => {\r\n console.log('Nucleus.Notifications: Failed to send notification registration to server.', error);\r\n _reject(error);\r\n });\r\n }).catch((error) => _reject(error));\r\n });\r\n }\r\n\r\n public unregister(): Promise<any> {\r\n return new Promise((_resolve, _reject) => {\r\n this.getRegistrationInfo().then((info) => {\r\n this.http.request<any>('DELETE', this.apiUrl + 'registration', { body: info }).subscribe(() => {\r\n window.localStorage.removeItem(this.registrationStorageKey);\r\n _resolve(null);\r\n }, error => {\r\n console.log('Nucleus.Notifications: Failed to remove registration from server.', error);\r\n _reject(error);\r\n });\r\n }).catch((error) => _reject(error));\r\n });\r\n }\r\n\r\n public refresh(notifyAboutNew = false) {\r\n this.http.get<Notification[]>(this.apiUrl + 'notifications').subscribe(res => {\r\n this.updateNotifications(res, notifyAboutNew);\r\n });\r\n }\r\n\r\n public getNotification(id: string): Observable<Notification> {\r\n const localNotification = this.notifications.find(x => x.id === id);\r\n if (localNotification) {\r\n return of(localNotification);\r\n }\r\n return this.http.get<Notification>(this.apiUrl + 'notifications/' + id);\r\n }\r\n\r\n public readNotification(id: string) {\r\n const n = this.notifications.find(x => x.id === id);\r\n if (n && !n.isRead) {\r\n n.isRead = true;\r\n this.notifyStateChanged();\r\n }\r\n this.http.get(this.apiUrl + 'notifications/read/' + id).subscribe();\r\n }\r\n\r\n public dismissNotification(id: string) {\r\n this.deleteNotificaton(id);\r\n this.http.delete(this.apiUrl + 'notifications/' + id).subscribe();\r\n this.removeDeliveredNotification(id);\r\n }\r\n\r\n public dismissAll() {\r\n this.notifications.splice(0);\r\n this.notifyStateChanged();\r\n this.http.delete(this.apiUrl + 'notifications/all').subscribe();\r\n if (this._platform === 'ios' || this._platform === 'android') {\r\n PushNotifications.removeAllDeliveredNotifications();\r\n } else if (this._platform === 'web') {\r\n // TODO: remove all web push notifications\r\n }\r\n }\r\n\r\n public readAll() {\r\n for (const n of this.notifications) {\r\n n.isRead = true;\r\n }\r\n this.notifyStateChanged();\r\n this.http.get(this.apiUrl + 'notifications/read/all').subscribe();\r\n }\r\n\r\n public getChannelConfig(senderId: string, channelId: string, language: string = null) {\r\n return this.http.get<UserChannelConfig>(this.apiUrl + `settings/channel/${senderId}/${channelId}?language=${language}`);\r\n }\r\n\r\n public getChannelConfigsForSender(senderId: string, channelIds: string[], language: string = null) {\r\n const idsStr = channelIds.map(x => senderId + ',' + x).join(';');\r\n return this.getChannelConfigsInternal(idsStr, language);\r\n }\r\n\r\n public getChannelConfigs(ids: ChannelId[], language: string = null) {\r\n const idsStr = ids.map(x => x.senderId + ',' + x.channelId).join(';');\r\n return this.getChannelConfigsInternal(idsStr, language);\r\n }\r\n\r\n public setChannelConfig(senderId: string, config: UserChannelConfig) {\r\n return this.http.post<void>(`${this.apiUrl}settings/channel/${senderId}`, config);\r\n }\r\n\r\n public setChannelConfigs(configs: UserChannelConfig[]) {\r\n return this.http.post<void>(`${this.apiUrl}settings/channels`, configs);\r\n }\r\n\r\n private getChannelConfigsInternal(ids: string, language: string) {\r\n return this.http.get<UserChannelConfig[]>(`${this.apiUrl}settings/channels?ids=${ids}&language=${language}`);\r\n }\r\n\r\n private updateNotifications(newNotifications: Notification[], notifyAboutNew = false) {\r\n let stateChanged = false;\r\n for (const n of newNotifications) {\r\n const existing = this.notifications.find(x => x.id === n.id);\r\n if (existing) {\r\n if (existing.isRead !== n.isRead) {\r\n existing.isRead = n.isRead;\r\n stateChanged = true;\r\n }\r\n } else {\r\n let i = 0;\r\n while (i < this.notifications.length && n.dateCreated < this.notifications[i].dateCreated) {\r\n i++;\r\n }\r\n this.notifications.splice(i, 0, n);\r\n stateChanged = true;\r\n if (notifyAboutNew) {\r\n this._newNotifications.next(n);\r\n }\r\n }\r\n }\r\n\r\n const now = Date.now();\r\n for (let i = this.notifications.length - 1; i >= 0; i--) {\r\n const n = this.notifications[i];\r\n if (new Date(n.expirationDate).getTime() < now || !newNotifications.find(x => x.id === n.id)) {\r\n this.notifications.splice(i, 1);\r\n stateChanged = true;\r\n }\r\n }\r\n\r\n if (stateChanged) {\r\n this.notifyStateChanged();\r\n }\r\n }\r\n\r\n private saveToStorage() {\r\n const str = JSON.stringify(this.notifications);\r\n window.localStorage.setItem(this.notificationsStorageKey, str);\r\n }\r\n\r\n private loadFromStorage() {\r\n try {\r\n const str = window.localStorage.getItem(this.notificationsStorageKey);\r\n if (str) {\r\n const notifications = JSON.parse(str) as Notification[];\r\n this.notifications = notifications.filter(x => !!x);\r\n // precaution for notification.isRead of undefined error\r\n this.notifyStateChanged(false);\r\n }\r\n } catch { }\r\n }\r\n\r\n private handleNotificationEvent(id: string, eventType: NotificationEventType) {\r\n if (eventType.startsWith('new') || eventType === 'updated') { // we are handling new and newSilent\r\n this.getNotification(id).subscribe(n => {\r\n if (eventType.startsWith('new') && !n.isRead) {\r\n this._newNotifications.next(n);\r\n }\r\n const existing = this.notifications.find(x => x.id === n.id);\r\n if (existing) {\r\n existing.isRead = n.isRead;\r\n } else {\r\n this.notifications.splice(0, 0, n);\r\n }\r\n this.notifyStateChanged();\r\n });\r\n } else if (eventType === 'deleted') {\r\n this.deleteNotificaton(id);\r\n } else {\r\n this.refresh();\r\n }\r\n }\r\n\r\n private deleteNotificaton(id: string) {\r\n const i = this.notifications.findIndex(x => x.id === id);\r\n if (i >= 0) {\r\n this.notifications.splice(i, 1);\r\n this.notifyStateChanged();\r\n }\r\n }\r\n\r\n private notifyStateChanged(persistState = true) {\r\n if (persistState) {\r\n this.saveToStorage();\r\n }\r\n this._stateChangesSubject.next();\r\n }\r\n\r\n private handleNotificationAction(notificationAction: string) {\r\n const arr = notificationAction.split(':');\r\n const notificationClick: NotificationClick = {\r\n id: arr[0],\r\n type: arr[1] as NotificationType,\r\n routerLink: arr[2]\r\n };\r\n\r\n const validNotificationClickTypes = ['default', 'deeplink'];\r\n if (validNotificationClickTypes.includes(notificationClick.type)) {\r\n this._clicksSubject.next(notificationClick);\r\n } else {\r\n console.error(`Nucleus.Notifications: Unknown notification action: '${notificationAction}'.`);\r\n }\r\n }\r\n\r\n private removeDeliveredNotification(id: string) {\r\n if (this._platform === 'ios' || this._platform === 'android') {\r\n PushNotifications.getDeliveredNotifications().then(list => {\r\n const toRemove = list.notifications.filter(n => {\r\n const data = this.getNotificationPayloadData(n);\r\n return (data.notificationId === id);\r\n });\r\n\r\n // TODO: On Android this does not currently work because notificationID is not set.\r\n // This my solve the issue: https://github.com/ionic-team/capacitor/pull/3523\r\n PushNotifications.removeDeliveredNotifications({\r\n notifications: toRemove\r\n });\r\n });\r\n } else if (this._platform === 'web') {\r\n // TODO: remove web push notification\r\n }\r\n }\r\n\r\n private getNotificationPayloadData(pushNotification: PushNotificationSchema): PayloadData {\r\n return (this._platform === 'ios') ? pushNotification.data.data : pushNotification.data;\r\n }\r\n\r\n private async registerCapacitorEvents() {\r\n await PushNotifications.addListener('pushNotificationReceived', n => {\r\n const data = this.getNotificationPayloadData(n);\r\n console.log('Nucleus.Notifications: Received capacitor push event: ' + data.eventType, n);\r\n this.handleNotificationEvent(data.notificationId, data.eventType);\r\n });\r\n\r\n await PushNotifications.addListener('pushNotificationActionPerformed', a => {\r\n let action = (a as any).notification.data.notificationAction;\r\n if (this._platform === 'ios') {\r\n action = (a as any).notification.data.data.notificationAction;\r\n }\r\n console.log('Nucleus.Notifications: Received capacitor action event', action);\r\n this.handleNotificationAction(action);\r\n });\r\n }\r\n\r\n private registerWebPushEvents() {\r\n this.swPush.messages.subscribe((n) => {\r\n const data: PayloadData = (n as any).data;\r\n console.log('Nucleus.Notifications: Received WebPush event: ' + data.eventType, n);\r\n this.handleNotificationEvent(data.notificationId, data.eventType);\r\n });\r\n\r\n this.swPush.notificationClicks.subscribe((action) => {\r\n console.log('Nucleus.Notifications: Received WebPush action event', action);\r\n const tag = action.notification.tag;\r\n this.handleNotificationAction(tag);\r\n });\r\n }\r\n\r\n private getRegistrationInfo(): Promise<Registration> {\r\n return new Promise((_resolve, _reject) => {\r\n const registrationId = window.localStorage.getItem(this.registrationStorageKey);\r\n if (this._platform === 'android' || this._platform === 'ios') {\r\n // capacitor platform\r\n const listener = PushNotifications.addListener('registration', token => {\r\n listener.remove();\r\n _resolve({ id: registrationId, token: token.value, platform: this._platform });\r\n });\r\n PushNotifications.register().catch(error => _reject('Could not register for notifications:' + error));\r\n } else if (this._platform === 'web') {\r\n // Web Push API\r\n this.http.get<WebKey>(this.apiUrl + 'registration/webkey').subscribe(key => {\r\n this.getWebPushSubscription(key.publicKey).then(subscription => {\r\n const t = JSON.stringify(subscription.toJSON());\r\n _resolve({ id: registrationId, token: t, platform: 'web' });\r\n });\r\n }, error => _reject(error));\r\n } else {\r\n _reject(`Nucleus.Notifications: Platform is not supported`);\r\n }\r\n });\r\n }\r\n\r\n private getWebPushSubscription(publicKey: string): Promise<PushSubscription> {\r\n return new Promise((_resolve, _reject) => {\r\n this.swPush.subscription.subscribe(subscription => {\r\n if (subscription != null) {\r\n _resolve(subscription);\r\n } else {\r\n this.swPush.requestSubscription({ serverPublicKey: publicKey }).then(s => _resolve(s)).catch(e => _reject(e));\r\n }\r\n }, error => {\r\n console.error('Nucleus.Notifications: Cannot get web push subscription', error);\r\n _reject(error);\r\n });\r\n });\r\n }\r\n}\r\n","import { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { NucleusNotificationsConfig } from './models';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n ],\r\n exports: []\r\n})\r\nexport class NucleusNotificationsModule {\r\n\r\n static forRoot(config: NucleusNotificationsConfig): ModuleWithProviders<NucleusNotificationsModule> {\r\n return {\r\n ngModule: NucleusNotificationsModule,\r\n providers: [\r\n { provide: NucleusNotificationsConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n}\r\n","/*\r\n * Public API Surface of nucleus-notifications\r\n */\r\n\r\nexport * from './lib/nucleus-notifications.service';\r\nexport * from './lib/nucleus-notifications.module';\r\nexport * from './lib/models';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAAa,YAAY;CAOxB;MAEY,QAAQ;CAIpB;MAEY,SAAS;CAIrB;MAEY,gBAAgB;CAM5B;MAEY,MAAM;CAElB;MAEY,YAAY;CAIxB;MAEY,kBAAkB;CAE9B;MAEY,WAAW;CAGvB;MAEY,0BAA0B;CAEtC;MAEY,iBAAiB;CAI7B;MAaY,iBAAiB;;;MC7CjB,2BAA2B;IAEtC,YACU,IAAgB,EAChB,MAAc,EACd,UAA6B,EACrC,MAAkC;QAH1B,SAAI,GAAJ,IAAI,CAAY;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAmB;QAU/B,WAAM,GAAG,IAAI,CAAC;QACL,2BAAsB,GAAG,oCAAoC,CAAC;QAC9D,4BAAuB,GAAG,gCAAgC,CAAC;QAEpE,mBAAc,GAAG,KAAK,CAAC;QACvB,sBAAiB,GAAG,IAAI,OAAO,EAAgB,CAAC;QAChD,mBAAc,GAAG,IAAI,OAAO,EAAqB,CAAC;QAClD,yBAAoB,GAAG,IAAI,OAAO,EAAQ,CAAC;QAE5C,kBAAa,GAAmB,EAAE,CAAC;QAhBxC,IAAI,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACtB,GAAG,IAAI,GAAG,CAAC;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2FAEP,2BAA2B;kBAHvC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB;;;MCdY,0BAA0B;IAErC,OAAO,OAAO,CAAC,MAAkC;QAC/C,OAAO;YACL,QAAQ,EAAE,0BAA0B;YACpC,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,EAAE;aAC1D;SACF,CAAC;KACH;;uHATU,0BAA0B;wHAA1B,0BAA0B;wHAA1B,0BAA0B,YAJ5B,EACR;2FAGU,0BAA0B;kBANtC,QAAQ;mBAAC;oBACR,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,EACR;oBACD,OAAO,EAAE,EAAE;iBACZ;;;ACRD;;;;ACAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"kolektor-nucleus-notifications.mjs","sources":["../../../projects/nucleus-notifications/src/lib/models.ts","../../../projects/nucleus-notifications/src/lib/nucleus-notifications.service.ts","../../../projects/nucleus-notifications/src/lib/nucleus-notifications.module.ts","../../../projects/nucleus-notifications/src/public-api.ts","../../../projects/nucleus-notifications/src/kolektor-nucleus-notifications.ts"],"sourcesContent":["export class Notification {\r\n public id: string;\r\n public sender: Identity;\r\n public data: NotificationData;\r\n public isRead: boolean;\r\n public dateCreated: Date;\r\n public expirationDate: Date;\r\n}\r\n\r\nexport class Identity {\r\n public subject: string;\r\n public name: string;\r\n public pictureUrl: string;\r\n}\r\n\r\nexport class Recipient {\r\n public attributeName: string;\r\n public directoryName: string;\r\n public attributeValue: string;\r\n}\r\n\r\nexport class NotificationData {\r\n title: string;\r\n message: string;\r\n htmlMessage: string;\r\n preventDismissal: boolean;\r\n deepLink: string;\r\n}\r\n\r\nexport class WebKey {\r\n publicKey: string;\r\n}\r\n\r\nexport class Registration {\r\n id: string;\r\n token: string;\r\n platform: PlatformValue;\r\n}\r\n\r\nexport class RegistrationResult {\r\n id: string;\r\n}\r\n\r\nexport class PayloadData {\r\n notificationId: string;\r\n eventType: NotificationEventType;\r\n}\r\n\r\nexport class NucleusNotificationsConfig {\r\n serverApiUrl: string;\r\n}\r\n\r\nexport class NotificationClick {\r\n id: string;\r\n type: NotificationType;\r\n routerLink?: string;\r\n}\r\n\r\nexport type NotificationEventType = 'new' | 'updated' | 'deleted' | 'deletedAll' | 'updatedAll' | 'newSilent';\r\n\r\nexport type PlatformValue = 'ios' | 'android' | 'web' | 'none';\r\n\r\nexport type NotificationType = 'default' | 'deeplink';\r\n\r\nexport interface ChannelId {\r\n senderId: string;\r\n channelId: string;\r\n}\r\n\r\nexport class UserChannelConfig {\r\n channelId: string;\r\n displayName: string;\r\n isSubscribed: boolean;\r\n subscriptionType: ChannelSubscriptionType;\r\n methods: NotifyMethod[];\r\n allowedMethods: NotifyMethod[];\r\n}\r\n\r\nexport type ChannelSubscriptionType = 'invariant' | 'optIn' | 'optOut';\r\n\r\nexport type NotifyMethod = 'push' | 'email' | 'sms';\r\n","import { HttpClient } from '@angular/common/http';\r\nimport { Injectable } from '@angular/core';\r\nimport { SwPush } from '@angular/service-worker';\r\nimport { PushNotifications, PushNotificationSchema } from '@capacitor/push-notifications';\r\nimport { NucleusAppService } from '@kolektor/nucleus-common';\r\nimport { Observable, of, Subject } from 'rxjs';\r\nimport {\r\n ChannelId,\r\n Notification,\r\n NotificationClick,\r\n NotificationEventType,\r\n NotificationType,\r\n NucleusNotificationsConfig,\r\n PayloadData,\r\n PlatformValue,\r\n Registration,\r\n RegistrationResult,\r\n UserChannelConfig,\r\n WebKey\r\n} from './models';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class NucleusNotificationsService {\r\n\r\n constructor(\r\n private http: HttpClient,\r\n private swPush: SwPush,\r\n private appService: NucleusAppService,\r\n config: NucleusNotificationsConfig\r\n ) {\r\n let url = config.serverApiUrl;\r\n if (!url.endsWith('/')) {\r\n url += '/';\r\n }\r\n this.apiUrl = url;\r\n }\r\n\r\n private apiUrl = null;\r\n private readonly registrationStorageKey = 'NucleusNotificationsRegistrationId';\r\n private readonly notificationsStorageKey = 'NucleusNotificationsLocalCache';\r\n private _platform: PlatformValue;\r\n private _isInitialized = false;\r\n private _newNotifications = new Subject<Notification>();\r\n private _clicksSubject = new Subject<NotificationClick>();\r\n private _stateChangesSubject = new Subject<void>();\r\n\r\n public notifications: Notification[] = [];\r\n\r\n public get unreadCount() {\r\n return this.notifications.filter(x => !x.isRead).length;\r\n }\r\n\r\n public get newNotifications() {\r\n return this._newNotifications.asObservable();\r\n }\r\n\r\n public get clicks() {\r\n return this._clicksSubject.asObservable();\r\n }\r\n public get stateChanges() {\r\n return this._stateChangesSubject.asObservable();\r\n }\r\n\r\n public get isInitialized() {\r\n return this._isInitialized;\r\n }\r\n\r\n public async initialize() {\r\n // make sure app service has finished initializing\r\n await this.appService.init();\r\n\r\n this.loadFromStorage();\r\n\r\n if (this.appService.isNative) {\r\n this._platform = this.appService.deviceInfo.platform as PlatformValue;\r\n await this.registerCapacitorEvents();\r\n } else if (this.swPush.isEnabled) {\r\n this._platform = 'web';\r\n this.registerWebPushEvents();\r\n } else {\r\n console.warn('Nucleus.Notifications: There is no push capability, timer will be used to update notifications');\r\n setInterval(() => {\r\n console.log('Updating notifications...');\r\n this.refresh(true);\r\n }, 5 * 60 * 1000);\r\n }\r\n this._isInitialized = true;\r\n this.refresh();\r\n }\r\n\r\n public register(): Promise<any> {\r\n return new Promise((_resolve, _reject) => {\r\n this.getRegistrationInfo().then((info) => {\r\n this.http.post<RegistrationResult>(this.apiUrl + 'registration', info).subscribe((regResult) => {\r\n window.localStorage.setItem(this.registrationStorageKey, regResult.id);\r\n _resolve(null);\r\n }, error => {\r\n console.log('Nucleus.Notifications: Failed to send notification registration to server.', error);\r\n _reject(error);\r\n });\r\n }).catch((error) => _reject(error));\r\n });\r\n }\r\n\r\n public unregister(): Promise<any> {\r\n return new Promise((_resolve, _reject) => {\r\n this.getRegistrationInfo().then((info) => {\r\n this.http.request<any>('DELETE', this.apiUrl + 'registration', { body: info }).subscribe(() => {\r\n window.localStorage.removeItem(this.registrationStorageKey);\r\n _resolve(null);\r\n }, error => {\r\n console.log('Nucleus.Notifications: Failed to remove registration from server.', error);\r\n _reject(error);\r\n });\r\n }).catch((error) => _reject(error));\r\n });\r\n }\r\n\r\n public refresh(notifyAboutNew = false) {\r\n this.http.get<Notification[]>(this.apiUrl + 'notifications').subscribe(res => {\r\n this.updateNotifications(res, notifyAboutNew);\r\n });\r\n }\r\n\r\n public getNotification(id: string): Observable<Notification> {\r\n const localNotification = this.notifications.find(x => x.id === id);\r\n if (localNotification) {\r\n return of(localNotification);\r\n }\r\n return this.http.get<Notification>(this.apiUrl + 'notifications/' + id);\r\n }\r\n\r\n public readNotification(id: string) {\r\n const n = this.notifications.find(x => x.id === id);\r\n if (n && !n.isRead) {\r\n n.isRead = true;\r\n this.notifyStateChanged();\r\n }\r\n this.http.get(this.apiUrl + 'notifications/read/' + id).subscribe();\r\n }\r\n\r\n public dismissNotification(id: string) {\r\n this.deleteNotificaton(id);\r\n this.http.delete(this.apiUrl + 'notifications/' + id).subscribe();\r\n this.removeDeliveredNotification(id);\r\n }\r\n\r\n public dismissAll() {\r\n this.notifications.splice(0);\r\n this.notifyStateChanged();\r\n this.http.delete(this.apiUrl + 'notifications/all').subscribe();\r\n if (this._platform === 'ios' || this._platform === 'android') {\r\n PushNotifications.removeAllDeliveredNotifications();\r\n } else if (this._platform === 'web') {\r\n // TODO: remove all web push notifications\r\n }\r\n }\r\n\r\n public readAll() {\r\n for (const n of this.notifications) {\r\n n.isRead = true;\r\n }\r\n this.notifyStateChanged();\r\n this.http.get(this.apiUrl + 'notifications/read/all').subscribe();\r\n }\r\n\r\n public getChannelConfig(senderId: string, channelId: string, language: string = null) {\r\n return this.http.get<UserChannelConfig>(this.apiUrl + `settings/channel/${senderId}/${channelId}?language=${language}`);\r\n }\r\n\r\n public getChannelConfigsForSender(senderId: string, channelIds: string[], language: string = null) {\r\n const idsStr = channelIds.map(x => senderId + ',' + x).join(';');\r\n return this.getChannelConfigsInternal(idsStr, language);\r\n }\r\n\r\n public getChannelConfigs(ids: ChannelId[], language: string = null) {\r\n const idsStr = ids.map(x => x.senderId + ',' + x.channelId).join(';');\r\n return this.getChannelConfigsInternal(idsStr, language);\r\n }\r\n\r\n public setChannelConfig(senderId: string, config: UserChannelConfig) {\r\n return this.http.post<void>(`${this.apiUrl}settings/channel/${senderId}`, config);\r\n }\r\n\r\n public setChannelConfigs(configs: UserChannelConfig[]) {\r\n return this.http.post<void>(`${this.apiUrl}settings/channels`, configs);\r\n }\r\n\r\n private getChannelConfigsInternal(ids: string, language: string) {\r\n return this.http.get<UserChannelConfig[]>(`${this.apiUrl}settings/channels?ids=${ids}&language=${language}`);\r\n }\r\n\r\n private updateNotifications(newNotifications: Notification[], notifyAboutNew = false) {\r\n let stateChanged = false;\r\n for (const n of newNotifications) {\r\n const existing = this.notifications.find(x => x.id === n.id);\r\n if (existing) {\r\n if (existing.isRead !== n.isRead) {\r\n existing.isRead = n.isRead;\r\n stateChanged = true;\r\n }\r\n } else {\r\n let i = 0;\r\n while (i < this.notifications.length && n.dateCreated < this.notifications[i].dateCreated) {\r\n i++;\r\n }\r\n this.notifications.splice(i, 0, n);\r\n stateChanged = true;\r\n if (notifyAboutNew) {\r\n this._newNotifications.next(n);\r\n }\r\n }\r\n }\r\n\r\n const now = Date.now();\r\n for (let i = this.notifications.length - 1; i >= 0; i--) {\r\n const n = this.notifications[i];\r\n if (new Date(n.expirationDate).getTime() < now || !newNotifications.find(x => x.id === n.id)) {\r\n this.notifications.splice(i, 1);\r\n stateChanged = true;\r\n }\r\n }\r\n\r\n if (stateChanged) {\r\n this.notifyStateChanged();\r\n }\r\n }\r\n\r\n private saveToStorage() {\r\n const str = JSON.stringify(this.notifications);\r\n window.localStorage.setItem(this.notificationsStorageKey, str);\r\n }\r\n\r\n private loadFromStorage() {\r\n try {\r\n const str = window.localStorage.getItem(this.notificationsStorageKey);\r\n if (str) {\r\n const notifications = JSON.parse(str) as Notification[];\r\n this.notifications = notifications.filter(x => !!x);\r\n // precaution for notification.isRead of undefined error\r\n this.notifyStateChanged(false);\r\n }\r\n } catch { }\r\n }\r\n\r\n private handleNotificationEvent(id: string, eventType: NotificationEventType) {\r\n if (eventType.startsWith('new') || eventType === 'updated') { // we are handling new and newSilent\r\n this.getNotification(id).subscribe(n => {\r\n if (eventType.startsWith('new') && !n.isRead) {\r\n this._newNotifications.next(n);\r\n }\r\n const existing = this.notifications.find(x => x.id === n.id);\r\n if (existing) {\r\n existing.isRead = n.isRead;\r\n } else {\r\n this.notifications.splice(0, 0, n);\r\n }\r\n this.notifyStateChanged();\r\n });\r\n } else if (eventType === 'deleted') {\r\n this.deleteNotificaton(id);\r\n } else {\r\n this.refresh();\r\n }\r\n }\r\n\r\n private deleteNotificaton(id: string) {\r\n const i = this.notifications.findIndex(x => x.id === id);\r\n if (i >= 0) {\r\n this.notifications.splice(i, 1);\r\n this.notifyStateChanged();\r\n }\r\n }\r\n\r\n private notifyStateChanged(persistState = true) {\r\n if (persistState) {\r\n this.saveToStorage();\r\n }\r\n this._stateChangesSubject.next();\r\n }\r\n\r\n private handleNotificationAction(notificationAction: string) {\r\n const arr = notificationAction.split(':');\r\n const notificationClick: NotificationClick = {\r\n id: arr[0],\r\n type: arr[1] as NotificationType,\r\n routerLink: arr[2]\r\n };\r\n\r\n const validNotificationClickTypes = ['default', 'deeplink'];\r\n if (validNotificationClickTypes.includes(notificationClick.type)) {\r\n this._clicksSubject.next(notificationClick);\r\n } else {\r\n console.error(`Nucleus.Notifications: Unknown notification action: '${notificationAction}'.`);\r\n }\r\n }\r\n\r\n private removeDeliveredNotification(id: string) {\r\n if (this._platform === 'ios' || this._platform === 'android') {\r\n PushNotifications.getDeliveredNotifications().then(list => {\r\n const toRemove = list.notifications.filter(n => {\r\n const data = this.getNotificationPayloadData(n);\r\n return (data.notificationId === id);\r\n });\r\n\r\n // TODO: On Android this does not currently work because notificationID is not set.\r\n // This my solve the issue: https://github.com/ionic-team/capacitor/pull/3523\r\n PushNotifications.removeDeliveredNotifications({\r\n notifications: toRemove\r\n });\r\n });\r\n } else if (this._platform === 'web') {\r\n // TODO: remove web push notification\r\n }\r\n }\r\n\r\n private getNotificationPayloadData(pushNotification: PushNotificationSchema): PayloadData {\r\n return (this._platform === 'ios') ? pushNotification.data.data : pushNotification.data;\r\n }\r\n\r\n private async registerCapacitorEvents() {\r\n await PushNotifications.addListener('pushNotificationReceived', n => {\r\n const data = this.getNotificationPayloadData(n);\r\n console.log('Nucleus.Notifications: Received capacitor push event: ' + data.eventType, n);\r\n this.handleNotificationEvent(data.notificationId, data.eventType);\r\n });\r\n\r\n await PushNotifications.addListener('pushNotificationActionPerformed', a => {\r\n let action = (a as any).notification.data.notificationAction;\r\n if (this._platform === 'ios') {\r\n action = (a as any).notification.data.data.notificationAction;\r\n }\r\n console.log('Nucleus.Notifications: Received capacitor action event', action);\r\n this.handleNotificationAction(action);\r\n });\r\n }\r\n\r\n private registerWebPushEvents() {\r\n this.swPush.messages.subscribe((n) => {\r\n const data: PayloadData = (n as any).data;\r\n console.log('Nucleus.Notifications: Received WebPush event: ' + data.eventType, n);\r\n this.handleNotificationEvent(data.notificationId, data.eventType);\r\n });\r\n\r\n this.swPush.notificationClicks.subscribe((action) => {\r\n console.log('Nucleus.Notifications: Received WebPush action event', action);\r\n const tag = action.notification.tag;\r\n this.handleNotificationAction(tag);\r\n });\r\n }\r\n\r\n private getRegistrationInfo(): Promise<Registration> {\r\n return new Promise((_resolve, _reject) => {\r\n const registrationId = window.localStorage.getItem(this.registrationStorageKey);\r\n if (this._platform === 'android' || this._platform === 'ios') {\r\n // capacitor platform\r\n const listener = PushNotifications.addListener('registration', token => {\r\n listener.remove();\r\n _resolve({ id: registrationId, token: token.value, platform: this._platform });\r\n });\r\n PushNotifications.register().catch(error => _reject('Could not register for notifications:' + error));\r\n } else if (this._platform === 'web') {\r\n // Web Push API\r\n this.http.get<WebKey>(this.apiUrl + 'registration/webkey').subscribe(key => {\r\n this.getWebPushSubscription(key.publicKey).then(subscription => {\r\n const t = JSON.stringify(subscription.toJSON());\r\n _resolve({ id: registrationId, token: t, platform: 'web' });\r\n });\r\n }, error => _reject(error));\r\n } else {\r\n _reject(`Nucleus.Notifications: Platform is not supported`);\r\n }\r\n });\r\n }\r\n\r\n private getWebPushSubscription(publicKey: string): Promise<PushSubscription> {\r\n return new Promise((_resolve, _reject) => {\r\n this.swPush.subscription.subscribe(subscription => {\r\n if (subscription != null) {\r\n _resolve(subscription);\r\n } else {\r\n this.swPush.requestSubscription({ serverPublicKey: publicKey }).then(s => _resolve(s)).catch(e => _reject(e));\r\n }\r\n }, error => {\r\n console.error('Nucleus.Notifications: Cannot get web push subscription', error);\r\n _reject(error);\r\n });\r\n });\r\n }\r\n}\r\n","import { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { NucleusNotificationsConfig } from './models';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n ],\r\n exports: []\r\n})\r\nexport class NucleusNotificationsModule {\r\n\r\n static forRoot(config: NucleusNotificationsConfig): ModuleWithProviders<NucleusNotificationsModule> {\r\n return {\r\n ngModule: NucleusNotificationsModule,\r\n providers: [\r\n { provide: NucleusNotificationsConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n}\r\n","/*\r\n * Public API Surface of nucleus-notifications\r\n */\r\n\r\nexport * from './lib/nucleus-notifications.service';\r\nexport * from './lib/nucleus-notifications.module';\r\nexport * from './lib/models';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i4.NucleusNotificationsConfig"],"mappings":";;;;;;;;;MAAa,YAAY,CAAA;AAOxB,CAAA;MAEY,QAAQ,CAAA;AAIpB,CAAA;MAEY,SAAS,CAAA;AAIrB,CAAA;MAEY,gBAAgB,CAAA;AAM5B,CAAA;MAEY,MAAM,CAAA;AAElB,CAAA;MAEY,YAAY,CAAA;AAIxB,CAAA;MAEY,kBAAkB,CAAA;AAE9B,CAAA;MAEY,WAAW,CAAA;A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
@@ -364,9 +364,9 @@ class NucleusNotificationsService {
|
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
NucleusNotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
368
|
-
NucleusNotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
369
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
367
|
+
NucleusNotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, deps: [{ token: i1.HttpClient }, { token: i2.SwPush }, { token: i3.NucleusAppService }, { token: NucleusNotificationsConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
368
|
+
NucleusNotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, providedIn: 'root' });
|
|
369
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsService, decorators: [{
|
|
370
370
|
type: Injectable,
|
|
371
371
|
args: [{
|
|
372
372
|
providedIn: 'root'
|
|
@@ -383,10 +383,10 @@ class NucleusNotificationsModule {
|
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
NucleusNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
387
|
-
NucleusNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
388
|
-
NucleusNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
389
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
386
|
+
NucleusNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
387
|
+
NucleusNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule });
|
|
388
|
+
NucleusNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule });
|
|
389
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: NucleusNotificationsModule, decorators: [{
|
|
390
390
|
type: NgModule,
|
|
391
391
|
args: [{
|
|
392
392
|
declarations: [],
|
|
@@ -404,3 +404,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
404
404
|
*/
|
|
405
405
|
|
|
406
406
|
export { Identity, Notification, NotificationClick, NotificationData, NucleusNotificationsConfig, NucleusNotificationsModule, NucleusNotificationsService, PayloadData, Recipient, Registration, RegistrationResult, UserChannelConfig, WebKey };
|
|
407
|
+
//# sourceMappingURL=kolektor-nucleus-notifications.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kolektor-nucleus-notifications.mjs","sources":["../../../projects/nucleus-notifications/src/lib/models.ts","../../../projects/nucleus-notifications/src/lib/nucleus-notifications.service.ts","../../../projects/nucleus-notifications/src/lib/nucleus-notifications.module.ts","../../../projects/nucleus-notifications/src/public-api.ts","../../../projects/nucleus-notifications/src/kolektor-nucleus-notifications.ts"],"sourcesContent":["export class Notification {\r\n public id: string;\r\n public sender: Identity;\r\n public data: NotificationData;\r\n public isRead: boolean;\r\n public dateCreated: Date;\r\n public expirationDate: Date;\r\n}\r\n\r\nexport class Identity {\r\n public subject: string;\r\n public name: string;\r\n public pictureUrl: string;\r\n}\r\n\r\nexport class Recipient {\r\n public attributeName: string;\r\n public directoryName: string;\r\n public attributeValue: string;\r\n}\r\n\r\nexport class NotificationData {\r\n title: string;\r\n message: string;\r\n htmlMessage: string;\r\n preventDismissal: boolean;\r\n deepLink: string;\r\n}\r\n\r\nexport class WebKey {\r\n publicKey: string;\r\n}\r\n\r\nexport class Registration {\r\n id: string;\r\n token: string;\r\n platform: PlatformValue;\r\n}\r\n\r\nexport class RegistrationResult {\r\n id: string;\r\n}\r\n\r\nexport class PayloadData {\r\n notificationId: string;\r\n eventType: NotificationEventType;\r\n}\r\n\r\nexport class NucleusNotificationsConfig {\r\n serverApiUrl: string;\r\n}\r\n\r\nexport class NotificationClick {\r\n id: string;\r\n type: NotificationType;\r\n routerLink?: string;\r\n}\r\n\r\nexport type NotificationEventType = 'new' | 'updated' | 'deleted' | 'deletedAll' | 'updatedAll' | 'newSilent';\r\n\r\nexport type PlatformValue = 'ios' | 'android' | 'web' | 'none';\r\n\r\nexport type NotificationType = 'default' | 'deeplink';\r\n\r\nexport interface ChannelId {\r\n senderId: string;\r\n channelId: string;\r\n}\r\n\r\nexport class UserChannelConfig {\r\n channelId: string;\r\n displayName: string;\r\n isSubscribed: boolean;\r\n subscriptionType: ChannelSubscriptionType;\r\n methods: NotifyMethod[];\r\n allowedMethods: NotifyMethod[];\r\n}\r\n\r\nexport type ChannelSubscriptionType = 'invariant' | 'optIn' | 'optOut';\r\n\r\nexport type NotifyMethod = 'push' | 'email' | 'sms';\r\n","import { HttpClient } from '@angular/common/http';\r\nimport { Injectable } from '@angular/core';\r\nimport { SwPush } from '@angular/service-worker';\r\nimport { PushNotifications, PushNotificationSchema } from '@capacitor/push-notifications';\r\nimport { NucleusAppService } from '@kolektor/nucleus-common';\r\nimport { Observable, of, Subject } from 'rxjs';\r\nimport {\r\n ChannelId,\r\n Notification,\r\n NotificationClick,\r\n NotificationEventType,\r\n NotificationType,\r\n NucleusNotificationsConfig,\r\n PayloadData,\r\n PlatformValue,\r\n Registration,\r\n RegistrationResult,\r\n UserChannelConfig,\r\n WebKey\r\n} from './models';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class NucleusNotificationsService {\r\n\r\n constructor(\r\n private http: HttpClient,\r\n private swPush: SwPush,\r\n private appService: NucleusAppService,\r\n config: NucleusNotificationsConfig\r\n ) {\r\n let url = config.serverApiUrl;\r\n if (!url.endsWith('/')) {\r\n url += '/';\r\n }\r\n this.apiUrl = url;\r\n }\r\n\r\n private apiUrl = null;\r\n private readonly registrationStorageKey = 'NucleusNotificationsRegistrationId';\r\n private readonly notificationsStorageKey = 'NucleusNotificationsLocalCache';\r\n private _platform: PlatformValue;\r\n private _isInitialized = false;\r\n private _newNotifications = new Subject<Notification>();\r\n private _clicksSubject = new Subject<NotificationClick>();\r\n private _stateChangesSubject = new Subject<void>();\r\n\r\n public notifications: Notification[] = [];\r\n\r\n public get unreadCount() {\r\n return this.notifications.filter(x => !x.isRead).length;\r\n }\r\n\r\n public get newNotifications() {\r\n return this._newNotifications.asObservable();\r\n }\r\n\r\n public get clicks() {\r\n return this._clicksSubject.asObservable();\r\n }\r\n public get stateChanges() {\r\n return this._stateChangesSubject.asObservable();\r\n }\r\n\r\n public get isInitialized() {\r\n return this._isInitialized;\r\n }\r\n\r\n public async initialize() {\r\n // make sure app service has finished initializing\r\n await this.appService.init();\r\n\r\n this.loadFromStorage();\r\n\r\n if (this.appService.isNative) {\r\n this._platform = this.appService.deviceInfo.platform as PlatformValue;\r\n await this.registerCapacitorEvents();\r\n } else if (this.swPush.isEnabled) {\r\n this._platform = 'web';\r\n this.registerWebPushEvents();\r\n } else {\r\n console.warn('Nucleus.Notifications: There is no push capability, timer will be used to update notifications');\r\n setInterval(() => {\r\n console.log('Updating notifications...');\r\n this.refresh(true);\r\n }, 5 * 60 * 1000);\r\n }\r\n this._isInitialized = true;\r\n this.refresh();\r\n }\r\n\r\n public register(): Promise<any> {\r\n return new Promise((_resolve, _reject) => {\r\n this.getRegistrationInfo().then((info) => {\r\n this.http.post<RegistrationResult>(this.apiUrl + 'registration', info).subscribe((regResult) => {\r\n window.localStorage.setItem(this.registrationStorageKey, regResult.id);\r\n _resolve(null);\r\n }, error => {\r\n console.log('Nucleus.Notifications: Failed to send notification registration to server.', error);\r\n _reject(error);\r\n });\r\n }).catch((error) => _reject(error));\r\n });\r\n }\r\n\r\n public unregister(): Promise<any> {\r\n return new Promise((_resolve, _reject) => {\r\n this.getRegistrationInfo().then((info) => {\r\n this.http.request<any>('DELETE', this.apiUrl + 'registration', { body: info }).subscribe(() => {\r\n window.localStorage.removeItem(this.registrationStorageKey);\r\n _resolve(null);\r\n }, error => {\r\n console.log('Nucleus.Notifications: Failed to remove registration from server.', error);\r\n _reject(error);\r\n });\r\n }).catch((error) => _reject(error));\r\n });\r\n }\r\n\r\n public refresh(notifyAboutNew = false) {\r\n this.http.get<Notification[]>(this.apiUrl + 'notifications').subscribe(res => {\r\n this.updateNotifications(res, notifyAboutNew);\r\n });\r\n }\r\n\r\n public getNotification(id: string): Observable<Notification> {\r\n const localNotification = this.notifications.find(x => x.id === id);\r\n if (localNotification) {\r\n return of(localNotification);\r\n }\r\n return this.http.get<Notification>(this.apiUrl + 'notifications/' + id);\r\n }\r\n\r\n public readNotification(id: string) {\r\n const n = this.notifications.find(x => x.id === id);\r\n if (n && !n.isRead) {\r\n n.isRead = true;\r\n this.notifyStateChanged();\r\n }\r\n this.http.get(this.apiUrl + 'notifications/read/' + id).subscribe();\r\n }\r\n\r\n public dismissNotification(id: string) {\r\n this.deleteNotificaton(id);\r\n this.http.delete(this.apiUrl + 'notifications/' + id).subscribe();\r\n this.removeDeliveredNotification(id);\r\n }\r\n\r\n public dismissAll() {\r\n this.notifications.splice(0);\r\n this.notifyStateChanged();\r\n this.http.delete(this.apiUrl + 'notifications/all').subscribe();\r\n if (this._platform === 'ios' || this._platform === 'android') {\r\n PushNotifications.removeAllDeliveredNotifications();\r\n } else if (this._platform === 'web') {\r\n // TODO: remove all web push notifications\r\n }\r\n }\r\n\r\n public readAll() {\r\n for (const n of this.notifications) {\r\n n.isRead = true;\r\n }\r\n this.notifyStateChanged();\r\n this.http.get(this.apiUrl + 'notifications/read/all').subscribe();\r\n }\r\n\r\n public getChannelConfig(senderId: string, channelId: string, language: string = null) {\r\n return this.http.get<UserChannelConfig>(this.apiUrl + `settings/channel/${senderId}/${channelId}?language=${language}`);\r\n }\r\n\r\n public getChannelConfigsForSender(senderId: string, channelIds: string[], language: string = null) {\r\n const idsStr = channelIds.map(x => senderId + ',' + x).join(';');\r\n return this.getChannelConfigsInternal(idsStr, language);\r\n }\r\n\r\n public getChannelConfigs(ids: ChannelId[], language: string = null) {\r\n const idsStr = ids.map(x => x.senderId + ',' + x.channelId).join(';');\r\n return this.getChannelConfigsInternal(idsStr, language);\r\n }\r\n\r\n public setChannelConfig(senderId: string, config: UserChannelConfig) {\r\n return this.http.post<void>(`${this.apiUrl}settings/channel/${senderId}`, config);\r\n }\r\n\r\n public setChannelConfigs(configs: UserChannelConfig[]) {\r\n return this.http.post<void>(`${this.apiUrl}settings/channels`, configs);\r\n }\r\n\r\n private getChannelConfigsInternal(ids: string, language: string) {\r\n return this.http.get<UserChannelConfig[]>(`${this.apiUrl}settings/channels?ids=${ids}&language=${language}`);\r\n }\r\n\r\n private updateNotifications(newNotifications: Notification[], notifyAboutNew = false) {\r\n let stateChanged = false;\r\n for (const n of newNotifications) {\r\n const existing = this.notifications.find(x => x.id === n.id);\r\n if (existing) {\r\n if (existing.isRead !== n.isRead) {\r\n existing.isRead = n.isRead;\r\n stateChanged = true;\r\n }\r\n } else {\r\n let i = 0;\r\n while (i < this.notifications.length && n.dateCreated < this.notifications[i].dateCreated) {\r\n i++;\r\n }\r\n this.notifications.splice(i, 0, n);\r\n stateChanged = true;\r\n if (notifyAboutNew) {\r\n this._newNotifications.next(n);\r\n }\r\n }\r\n }\r\n\r\n const now = Date.now();\r\n for (let i = this.notifications.length - 1; i >= 0; i--) {\r\n const n = this.notifications[i];\r\n if (new Date(n.expirationDate).getTime() < now || !newNotifications.find(x => x.id === n.id)) {\r\n this.notifications.splice(i, 1);\r\n stateChanged = true;\r\n }\r\n }\r\n\r\n if (stateChanged) {\r\n this.notifyStateChanged();\r\n }\r\n }\r\n\r\n private saveToStorage() {\r\n const str = JSON.stringify(this.notifications);\r\n window.localStorage.setItem(this.notificationsStorageKey, str);\r\n }\r\n\r\n private loadFromStorage() {\r\n try {\r\n const str = window.localStorage.getItem(this.notificationsStorageKey);\r\n if (str) {\r\n const notifications = JSON.parse(str) as Notification[];\r\n this.notifications = notifications.filter(x => !!x);\r\n // precaution for notification.isRead of undefined error\r\n this.notifyStateChanged(false);\r\n }\r\n } catch { }\r\n }\r\n\r\n private handleNotificationEvent(id: string, eventType: NotificationEventType) {\r\n if (eventType.startsWith('new') || eventType === 'updated') { // we are handling new and newSilent\r\n this.getNotification(id).subscribe(n => {\r\n if (eventType.startsWith('new') && !n.isRead) {\r\n this._newNotifications.next(n);\r\n }\r\n const existing = this.notifications.find(x => x.id === n.id);\r\n if (existing) {\r\n existing.isRead = n.isRead;\r\n } else {\r\n this.notifications.splice(0, 0, n);\r\n }\r\n this.notifyStateChanged();\r\n });\r\n } else if (eventType === 'deleted') {\r\n this.deleteNotificaton(id);\r\n } else {\r\n this.refresh();\r\n }\r\n }\r\n\r\n private deleteNotificaton(id: string) {\r\n const i = this.notifications.findIndex(x => x.id === id);\r\n if (i >= 0) {\r\n this.notifications.splice(i, 1);\r\n this.notifyStateChanged();\r\n }\r\n }\r\n\r\n private notifyStateChanged(persistState = true) {\r\n if (persistState) {\r\n this.saveToStorage();\r\n }\r\n this._stateChangesSubject.next();\r\n }\r\n\r\n private handleNotificationAction(notificationAction: string) {\r\n const arr = notificationAction.split(':');\r\n const notificationClick: NotificationClick = {\r\n id: arr[0],\r\n type: arr[1] as NotificationType,\r\n routerLink: arr[2]\r\n };\r\n\r\n const validNotificationClickTypes = ['default', 'deeplink'];\r\n if (validNotificationClickTypes.includes(notificationClick.type)) {\r\n this._clicksSubject.next(notificationClick);\r\n } else {\r\n console.error(`Nucleus.Notifications: Unknown notification action: '${notificationAction}'.`);\r\n }\r\n }\r\n\r\n private removeDeliveredNotification(id: string) {\r\n if (this._platform === 'ios' || this._platform === 'android') {\r\n PushNotifications.getDeliveredNotifications().then(list => {\r\n const toRemove = list.notifications.filter(n => {\r\n const data = this.getNotificationPayloadData(n);\r\n return (data.notificationId === id);\r\n });\r\n\r\n // TODO: On Android this does not currently work because notificationID is not set.\r\n // This my solve the issue: https://github.com/ionic-team/capacitor/pull/3523\r\n PushNotifications.removeDeliveredNotifications({\r\n notifications: toRemove\r\n });\r\n });\r\n } else if (this._platform === 'web') {\r\n // TODO: remove web push notification\r\n }\r\n }\r\n\r\n private getNotificationPayloadData(pushNotification: PushNotificationSchema): PayloadData {\r\n return (this._platform === 'ios') ? pushNotification.data.data : pushNotification.data;\r\n }\r\n\r\n private async registerCapacitorEvents() {\r\n await PushNotifications.addListener('pushNotificationReceived', n => {\r\n const data = this.getNotificationPayloadData(n);\r\n console.log('Nucleus.Notifications: Received capacitor push event: ' + data.eventType, n);\r\n this.handleNotificationEvent(data.notificationId, data.eventType);\r\n });\r\n\r\n await PushNotifications.addListener('pushNotificationActionPerformed', a => {\r\n let action = (a as any).notification.data.notificationAction;\r\n if (this._platform === 'ios') {\r\n action = (a as any).notification.data.data.notificationAction;\r\n }\r\n console.log('Nucleus.Notifications: Received capacitor action event', action);\r\n this.handleNotificationAction(action);\r\n });\r\n }\r\n\r\n private registerWebPushEvents() {\r\n this.swPush.messages.subscribe((n) => {\r\n const data: PayloadData = (n as any).data;\r\n console.log('Nucleus.Notifications: Received WebPush event: ' + data.eventType, n);\r\n this.handleNotificationEvent(data.notificationId, data.eventType);\r\n });\r\n\r\n this.swPush.notificationClicks.subscribe((action) => {\r\n console.log('Nucleus.Notifications: Received WebPush action event', action);\r\n const tag = action.notification.tag;\r\n this.handleNotificationAction(tag);\r\n });\r\n }\r\n\r\n private getRegistrationInfo(): Promise<Registration> {\r\n return new Promise((_resolve, _reject) => {\r\n const registrationId = window.localStorage.getItem(this.registrationStorageKey);\r\n if (this._platform === 'android' || this._platform === 'ios') {\r\n // capacitor platform\r\n const listener = PushNotifications.addListener('registration', token => {\r\n listener.remove();\r\n _resolve({ id: registrationId, token: token.value, platform: this._platform });\r\n });\r\n PushNotifications.register().catch(error => _reject('Could not register for notifications:' + error));\r\n } else if (this._platform === 'web') {\r\n // Web Push API\r\n this.http.get<WebKey>(this.apiUrl + 'registration/webkey').subscribe(key => {\r\n this.getWebPushSubscription(key.publicKey).then(subscription => {\r\n const t = JSON.stringify(subscription.toJSON());\r\n _resolve({ id: registrationId, token: t, platform: 'web' });\r\n });\r\n }, error => _reject(error));\r\n } else {\r\n _reject(`Nucleus.Notifications: Platform is not supported`);\r\n }\r\n });\r\n }\r\n\r\n private getWebPushSubscription(publicKey: string): Promise<PushSubscription> {\r\n return new Promise((_resolve, _reject) => {\r\n this.swPush.subscription.subscribe(subscription => {\r\n if (subscription != null) {\r\n _resolve(subscription);\r\n } else {\r\n this.swPush.requestSubscription({ serverPublicKey: publicKey }).then(s => _resolve(s)).catch(e => _reject(e));\r\n }\r\n }, error => {\r\n console.error('Nucleus.Notifications: Cannot get web push subscription', error);\r\n _reject(error);\r\n });\r\n });\r\n }\r\n}\r\n","import { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { NucleusNotificationsConfig } from './models';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n ],\r\n exports: []\r\n})\r\nexport class NucleusNotificationsModule {\r\n\r\n static forRoot(config: NucleusNotificationsConfig): ModuleWithProviders<NucleusNotificationsModule> {\r\n return {\r\n ngModule: NucleusNotificationsModule,\r\n providers: [\r\n { provide: NucleusNotificationsConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n}\r\n","/*\r\n * Public API Surface of nucleus-notifications\r\n */\r\n\r\nexport * from './lib/nucleus-notifications.service';\r\nexport * from './lib/nucleus-notifications.module';\r\nexport * from './lib/models';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAA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,EAAE;iBACZ;;;ACRD;;;;ACAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"kolektor-nucleus-notifications.mjs","sources":["../../../projects/nucleus-notifications/src/lib/models.ts","../../../projects/nucleus-notifications/src/lib/nucleus-notifications.service.ts","../../../projects/nucleus-notifications/src/lib/nucleus-notifications.module.ts","../../../projects/nucleus-notifications/src/public-api.ts","../../../projects/nucleus-notifications/src/kolektor-nucleus-notifications.ts"],"sourcesContent":["export class Notification {\r\n public id: string;\r\n public sender: Identity;\r\n public data: NotificationData;\r\n public isRead: boolean;\r\n public dateCreated: Date;\r\n public expirationDate: Date;\r\n}\r\n\r\nexport class Identity {\r\n public subject: string;\r\n public name: string;\r\n public pictureUrl: string;\r\n}\r\n\r\nexport class Recipient {\r\n public attributeName: string;\r\n public directoryName: string;\r\n public attributeValue: string;\r\n}\r\n\r\nexport class NotificationData {\r\n title: string;\r\n message: string;\r\n htmlMessage: string;\r\n preventDismissal: boolean;\r\n deepLink: string;\r\n}\r\n\r\nexport class WebKey {\r\n publicKey: string;\r\n}\r\n\r\nexport class Registration {\r\n id: string;\r\n token: string;\r\n platform: PlatformValue;\r\n}\r\n\r\nexport class RegistrationResult {\r\n id: string;\r\n}\r\n\r\nexport class PayloadData {\r\n notificationId: string;\r\n eventType: NotificationEventType;\r\n}\r\n\r\nexport class NucleusNotificationsConfig {\r\n serverApiUrl: string;\r\n}\r\n\r\nexport class NotificationClick {\r\n id: string;\r\n type: NotificationType;\r\n routerLink?: string;\r\n}\r\n\r\nexport type NotificationEventType = 'new' | 'updated' | 'deleted' | 'deletedAll' | 'updatedAll' | 'newSilent';\r\n\r\nexport type PlatformValue = 'ios' | 'android' | 'web' | 'none';\r\n\r\nexport type NotificationType = 'default' | 'deeplink';\r\n\r\nexport interface ChannelId {\r\n senderId: string;\r\n channelId: string;\r\n}\r\n\r\nexport class UserChannelConfig {\r\n channelId: string;\r\n displayName: string;\r\n isSubscribed: boolean;\r\n subscriptionType: ChannelSubscriptionType;\r\n methods: NotifyMethod[];\r\n allowedMethods: NotifyMethod[];\r\n}\r\n\r\nexport type ChannelSubscriptionType = 'invariant' | 'optIn' | 'optOut';\r\n\r\nexport type NotifyMethod = 'push' | 'email' | 'sms';\r\n","import { HttpClient } from '@angular/common/http';\r\nimport { Injectable } from '@angular/core';\r\nimport { SwPush } from '@angular/service-worker';\r\nimport { PushNotifications, PushNotificationSchema } from '@capacitor/push-notifications';\r\nimport { NucleusAppService } from '@kolektor/nucleus-common';\r\nimport { Observable, of, Subject } from 'rxjs';\r\nimport {\r\n ChannelId,\r\n Notification,\r\n NotificationClick,\r\n NotificationEventType,\r\n NotificationType,\r\n NucleusNotificationsConfig,\r\n PayloadData,\r\n PlatformValue,\r\n Registration,\r\n RegistrationResult,\r\n UserChannelConfig,\r\n WebKey\r\n} from './models';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class NucleusNotificationsService {\r\n\r\n constructor(\r\n private http: HttpClient,\r\n private swPush: SwPush,\r\n private appService: NucleusAppService,\r\n config: NucleusNotificationsConfig\r\n ) {\r\n let url = config.serverApiUrl;\r\n if (!url.endsWith('/')) {\r\n url += '/';\r\n }\r\n this.apiUrl = url;\r\n }\r\n\r\n private apiUrl = null;\r\n private readonly registrationStorageKey = 'NucleusNotificationsRegistrationId';\r\n private readonly notificationsStorageKey = 'NucleusNotificationsLocalCache';\r\n private _platform: PlatformValue;\r\n private _isInitialized = false;\r\n private _newNotifications = new Subject<Notification>();\r\n private _clicksSubject = new Subject<NotificationClick>();\r\n private _stateChangesSubject = new Subject<void>();\r\n\r\n public notifications: Notification[] = [];\r\n\r\n public get unreadCount() {\r\n return this.notifications.filter(x => !x.isRead).length;\r\n }\r\n\r\n public get newNotifications() {\r\n return this._newNotifications.asObservable();\r\n }\r\n\r\n public get clicks() {\r\n return this._clicksSubject.asObservable();\r\n }\r\n public get stateChanges() {\r\n return this._stateChangesSubject.asObservable();\r\n }\r\n\r\n public get isInitialized() {\r\n return this._isInitialized;\r\n }\r\n\r\n public async initialize() {\r\n // make sure app service has finished initializing\r\n await this.appService.init();\r\n\r\n this.loadFromStorage();\r\n\r\n if (this.appService.isNative) {\r\n this._platform = this.appService.deviceInfo.platform as PlatformValue;\r\n await this.registerCapacitorEvents();\r\n } else if (this.swPush.isEnabled) {\r\n this._platform = 'web';\r\n this.registerWebPushEvents();\r\n } else {\r\n console.warn('Nucleus.Notifications: There is no push capability, timer will be used to update notifications');\r\n setInterval(() => {\r\n console.log('Updating notifications...');\r\n this.refresh(true);\r\n }, 5 * 60 * 1000);\r\n }\r\n this._isInitialized = true;\r\n this.refresh();\r\n }\r\n\r\n public register(): Promise<any> {\r\n return new Promise((_resolve, _reject) => {\r\n this.getRegistrationInfo().then((info) => {\r\n this.http.post<RegistrationResult>(this.apiUrl + 'registration', info).subscribe((regResult) => {\r\n window.localStorage.setItem(this.registrationStorageKey, regResult.id);\r\n _resolve(null);\r\n }, error => {\r\n console.log('Nucleus.Notifications: Failed to send notification registration to server.', error);\r\n _reject(error);\r\n });\r\n }).catch((error) => _reject(error));\r\n });\r\n }\r\n\r\n public unregister(): Promise<any> {\r\n return new Promise((_resolve, _reject) => {\r\n this.getRegistrationInfo().then((info) => {\r\n this.http.request<any>('DELETE', this.apiUrl + 'registration', { body: info }).subscribe(() => {\r\n window.localStorage.removeItem(this.registrationStorageKey);\r\n _resolve(null);\r\n }, error => {\r\n console.log('Nucleus.Notifications: Failed to remove registration from server.', error);\r\n _reject(error);\r\n });\r\n }).catch((error) => _reject(error));\r\n });\r\n }\r\n\r\n public refresh(notifyAboutNew = false) {\r\n this.http.get<Notification[]>(this.apiUrl + 'notifications').subscribe(res => {\r\n this.updateNotifications(res, notifyAboutNew);\r\n });\r\n }\r\n\r\n public getNotification(id: string): Observable<Notification> {\r\n const localNotification = this.notifications.find(x => x.id === id);\r\n if (localNotification) {\r\n return of(localNotification);\r\n }\r\n return this.http.get<Notification>(this.apiUrl + 'notifications/' + id);\r\n }\r\n\r\n public readNotification(id: string) {\r\n const n = this.notifications.find(x => x.id === id);\r\n if (n && !n.isRead) {\r\n n.isRead = true;\r\n this.notifyStateChanged();\r\n }\r\n this.http.get(this.apiUrl + 'notifications/read/' + id).subscribe();\r\n }\r\n\r\n public dismissNotification(id: string) {\r\n this.deleteNotificaton(id);\r\n this.http.delete(this.apiUrl + 'notifications/' + id).subscribe();\r\n this.removeDeliveredNotification(id);\r\n }\r\n\r\n public dismissAll() {\r\n this.notifications.splice(0);\r\n this.notifyStateChanged();\r\n this.http.delete(this.apiUrl + 'notifications/all').subscribe();\r\n if (this._platform === 'ios' || this._platform === 'android') {\r\n PushNotifications.removeAllDeliveredNotifications();\r\n } else if (this._platform === 'web') {\r\n // TODO: remove all web push notifications\r\n }\r\n }\r\n\r\n public readAll() {\r\n for (const n of this.notifications) {\r\n n.isRead = true;\r\n }\r\n this.notifyStateChanged();\r\n this.http.get(this.apiUrl + 'notifications/read/all').subscribe();\r\n }\r\n\r\n public getChannelConfig(senderId: string, channelId: string, language: string = null) {\r\n return this.http.get<UserChannelConfig>(this.apiUrl + `settings/channel/${senderId}/${channelId}?language=${language}`);\r\n }\r\n\r\n public getChannelConfigsForSender(senderId: string, channelIds: string[], language: string = null) {\r\n const idsStr = channelIds.map(x => senderId + ',' + x).join(';');\r\n return this.getChannelConfigsInternal(idsStr, language);\r\n }\r\n\r\n public getChannelConfigs(ids: ChannelId[], language: string = null) {\r\n const idsStr = ids.map(x => x.senderId + ',' + x.channelId).join(';');\r\n return this.getChannelConfigsInternal(idsStr, language);\r\n }\r\n\r\n public setChannelConfig(senderId: string, config: UserChannelConfig) {\r\n return this.http.post<void>(`${this.apiUrl}settings/channel/${senderId}`, config);\r\n }\r\n\r\n public setChannelConfigs(configs: UserChannelConfig[]) {\r\n return this.http.post<void>(`${this.apiUrl}settings/channels`, configs);\r\n }\r\n\r\n private getChannelConfigsInternal(ids: string, language: string) {\r\n return this.http.get<UserChannelConfig[]>(`${this.apiUrl}settings/channels?ids=${ids}&language=${language}`);\r\n }\r\n\r\n private updateNotifications(newNotifications: Notification[], notifyAboutNew = false) {\r\n let stateChanged = false;\r\n for (const n of newNotifications) {\r\n const existing = this.notifications.find(x => x.id === n.id);\r\n if (existing) {\r\n if (existing.isRead !== n.isRead) {\r\n existing.isRead = n.isRead;\r\n stateChanged = true;\r\n }\r\n } else {\r\n let i = 0;\r\n while (i < this.notifications.length && n.dateCreated < this.notifications[i].dateCreated) {\r\n i++;\r\n }\r\n this.notifications.splice(i, 0, n);\r\n stateChanged = true;\r\n if (notifyAboutNew) {\r\n this._newNotifications.next(n);\r\n }\r\n }\r\n }\r\n\r\n const now = Date.now();\r\n for (let i = this.notifications.length - 1; i >= 0; i--) {\r\n const n = this.notifications[i];\r\n if (new Date(n.expirationDate).getTime() < now || !newNotifications.find(x => x.id === n.id)) {\r\n this.notifications.splice(i, 1);\r\n stateChanged = true;\r\n }\r\n }\r\n\r\n if (stateChanged) {\r\n this.notifyStateChanged();\r\n }\r\n }\r\n\r\n private saveToStorage() {\r\n const str = JSON.stringify(this.notifications);\r\n window.localStorage.setItem(this.notificationsStorageKey, str);\r\n }\r\n\r\n private loadFromStorage() {\r\n try {\r\n const str = window.localStorage.getItem(this.notificationsStorageKey);\r\n if (str) {\r\n const notifications = JSON.parse(str) as Notification[];\r\n this.notifications = notifications.filter(x => !!x);\r\n // precaution for notification.isRead of undefined error\r\n this.notifyStateChanged(false);\r\n }\r\n } catch { }\r\n }\r\n\r\n private handleNotificationEvent(id: string, eventType: NotificationEventType) {\r\n if (eventType.startsWith('new') || eventType === 'updated') { // we are handling new and newSilent\r\n this.getNotification(id).subscribe(n => {\r\n if (eventType.startsWith('new') && !n.isRead) {\r\n this._newNotifications.next(n);\r\n }\r\n const existing = this.notifications.find(x => x.id === n.id);\r\n if (existing) {\r\n existing.isRead = n.isRead;\r\n } else {\r\n this.notifications.splice(0, 0, n);\r\n }\r\n this.notifyStateChanged();\r\n });\r\n } else if (eventType === 'deleted') {\r\n this.deleteNotificaton(id);\r\n } else {\r\n this.refresh();\r\n }\r\n }\r\n\r\n private deleteNotificaton(id: string) {\r\n const i = this.notifications.findIndex(x => x.id === id);\r\n if (i >= 0) {\r\n this.notifications.splice(i, 1);\r\n this.notifyStateChanged();\r\n }\r\n }\r\n\r\n private notifyStateChanged(persistState = true) {\r\n if (persistState) {\r\n this.saveToStorage();\r\n }\r\n this._stateChangesSubject.next();\r\n }\r\n\r\n private handleNotificationAction(notificationAction: string) {\r\n const arr = notificationAction.split(':');\r\n const notificationClick: NotificationClick = {\r\n id: arr[0],\r\n type: arr[1] as NotificationType,\r\n routerLink: arr[2]\r\n };\r\n\r\n const validNotificationClickTypes = ['default', 'deeplink'];\r\n if (validNotificationClickTypes.includes(notificationClick.type)) {\r\n this._clicksSubject.next(notificationClick);\r\n } else {\r\n console.error(`Nucleus.Notifications: Unknown notification action: '${notificationAction}'.`);\r\n }\r\n }\r\n\r\n private removeDeliveredNotification(id: string) {\r\n if (this._platform === 'ios' || this._platform === 'android') {\r\n PushNotifications.getDeliveredNotifications().then(list => {\r\n const toRemove = list.notifications.filter(n => {\r\n const data = this.getNotificationPayloadData(n);\r\n return (data.notificationId === id);\r\n });\r\n\r\n // TODO: On Android this does not currently work because notificationID is not set.\r\n // This my solve the issue: https://github.com/ionic-team/capacitor/pull/3523\r\n PushNotifications.removeDeliveredNotifications({\r\n notifications: toRemove\r\n });\r\n });\r\n } else if (this._platform === 'web') {\r\n // TODO: remove web push notification\r\n }\r\n }\r\n\r\n private getNotificationPayloadData(pushNotification: PushNotificationSchema): PayloadData {\r\n return (this._platform === 'ios') ? pushNotification.data.data : pushNotification.data;\r\n }\r\n\r\n private async registerCapacitorEvents() {\r\n await PushNotifications.addListener('pushNotificationReceived', n => {\r\n const data = this.getNotificationPayloadData(n);\r\n console.log('Nucleus.Notifications: Received capacitor push event: ' + data.eventType, n);\r\n this.handleNotificationEvent(data.notificationId, data.eventType);\r\n });\r\n\r\n await PushNotifications.addListener('pushNotificationActionPerformed', a => {\r\n let action = (a as any).notification.data.notificationAction;\r\n if (this._platform === 'ios') {\r\n action = (a as any).notification.data.data.notificationAction;\r\n }\r\n console.log('Nucleus.Notifications: Received capacitor action event', action);\r\n this.handleNotificationAction(action);\r\n });\r\n }\r\n\r\n private registerWebPushEvents() {\r\n this.swPush.messages.subscribe((n) => {\r\n const data: PayloadData = (n as any).data;\r\n console.log('Nucleus.Notifications: Received WebPush event: ' + data.eventType, n);\r\n this.handleNotificationEvent(data.notificationId, data.eventType);\r\n });\r\n\r\n this.swPush.notificationClicks.subscribe((action) => {\r\n console.log('Nucleus.Notifications: Received WebPush action event', action);\r\n const tag = action.notification.tag;\r\n this.handleNotificationAction(tag);\r\n });\r\n }\r\n\r\n private getRegistrationInfo(): Promise<Registration> {\r\n return new Promise((_resolve, _reject) => {\r\n const registrationId = window.localStorage.getItem(this.registrationStorageKey);\r\n if (this._platform === 'android' || this._platform === 'ios') {\r\n // capacitor platform\r\n const listener = PushNotifications.addListener('registration', token => {\r\n listener.remove();\r\n _resolve({ id: registrationId, token: token.value, platform: this._platform });\r\n });\r\n PushNotifications.register().catch(error => _reject('Could not register for notifications:' + error));\r\n } else if (this._platform === 'web') {\r\n // Web Push API\r\n this.http.get<WebKey>(this.apiUrl + 'registration/webkey').subscribe(key => {\r\n this.getWebPushSubscription(key.publicKey).then(subscription => {\r\n const t = JSON.stringify(subscription.toJSON());\r\n _resolve({ id: registrationId, token: t, platform: 'web' });\r\n });\r\n }, error => _reject(error));\r\n } else {\r\n _reject(`Nucleus.Notifications: Platform is not supported`);\r\n }\r\n });\r\n }\r\n\r\n private getWebPushSubscription(publicKey: string): Promise<PushSubscription> {\r\n return new Promise((_resolve, _reject) => {\r\n this.swPush.subscription.subscribe(subscription => {\r\n if (subscription != null) {\r\n _resolve(subscription);\r\n } else {\r\n this.swPush.requestSubscription({ serverPublicKey: publicKey }).then(s => _resolve(s)).catch(e => _reject(e));\r\n }\r\n }, error => {\r\n console.error('Nucleus.Notifications: Cannot get web push subscription', error);\r\n _reject(error);\r\n });\r\n });\r\n }\r\n}\r\n","import { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { NucleusNotificationsConfig } from './models';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n ],\r\n exports: []\r\n})\r\nexport class NucleusNotificationsModule {\r\n\r\n static forRoot(config: NucleusNotificationsConfig): ModuleWithProviders<NucleusNotificationsModule> {\r\n return {\r\n ngModule: NucleusNotificationsModule,\r\n providers: [\r\n { provide: NucleusNotificationsConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n}\r\n","/*\r\n * Public API Surface of nucleus-notifications\r\n */\r\n\r\nexport * from './lib/nucleus-notifications.service';\r\nexport * from './lib/nucleus-notifications.module';\r\nexport * from './lib/models';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i4.NucleusNotificationsConfig"],"mappings":";;;;;;;;MAAa,YAAY,CAAA;AAOxB,CAAA;MAEY,QAAQ,CAAA;AAIpB,CAAA;MAEY,SAAS,CAAA;AAIrB,CAAA;MAEY,gBAAgB,CAAA;AAM5B,CAAA;MAEY,MAAM,CAAA;AAElB,CAAA;MAEY,YAAY,CAAA;AAIxB,CAAA;MAEY,kBAAkB,CAAA;AAE9B,CAAA;MAEY,WAAW,CAAA;AAGvB,CAAA;MAEY,0BAA0B,CAAA;AAEtC,CAAA;MAEY,iBAAiB,CAAA;AAI7B,CAAA;MAaY,iBAAiB,CAAA;AAO7B;;MCpDY,2BAA2B,CAAA;AAEtC,IAAA,WAAA,CACU,IAAgB,EAChB,MAAc,EACd,UAA6B,EACrC,MAAkC,EAAA;QAH1B,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;QAChB,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;QACd,IAAU,CAAA,UAAA,GAAV,UAAU,CAAmB;QAU/B,IAAM,CAAA,MAAA,GAAG,IAAI,CAAC;QACL,IAAsB,CAAA,sBAAA,GAAG,oCAAoC,CAAC;QAC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A,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;;MCdY,0BAA0B,CAAA;IAErC,OAAO,OAAO,CAAC,MAAkC,EAAA;QAC/C,OAAO;AACL,YAAA,QAAQ,EAAE,0BAA0B;AACpC,YAAA,SAAS,EAAE;AACT,gBAAA,EAAE,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1D,aAAA;SACF,CAAC;KACH;;uHATU,0BAA0B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;wHAA1B,0BAA0B,EAAA,CAAA,CAAA;wHAA1B,0BAA0B,EAAA,CAAA,CAAA;2FAA1B,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBANtC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE,EACR;AACD,oBAAA,OAAO,EAAE,EAAE;AACZ,iBAAA,CAAA;;;ACRD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolektor/nucleus-notifications",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10-pre.6137",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.0.0"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@angular/common": "^
|
|
9
|
-
"@angular/core": "^
|
|
10
|
-
"@angular/service-worker": "^
|
|
11
|
-
"@kolektor/nucleus-common": "^0.0.
|
|
8
|
+
"@angular/common": "^14.0.0",
|
|
9
|
+
"@angular/core": "^14.0.0",
|
|
10
|
+
"@angular/service-worker": "^14.0.0",
|
|
11
|
+
"@kolektor/nucleus-common": "^0.0.10-pre",
|
|
12
12
|
"@capacitor/core": "^3.0.0",
|
|
13
13
|
"@capacitor/push-notifications": "^1.0.0"
|
|
14
14
|
},
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"esm2020": "esm2020/kolektor-nucleus-notifications.mjs",
|
|
18
18
|
"fesm2020": "fesm2020/kolektor-nucleus-notifications.mjs",
|
|
19
19
|
"fesm2015": "fesm2015/kolektor-nucleus-notifications.mjs",
|
|
20
|
-
"typings": "
|
|
20
|
+
"typings": "index.d.ts",
|
|
21
21
|
"exports": {
|
|
22
22
|
"./package.json": {
|
|
23
23
|
"default": "./package.json"
|
|
24
24
|
},
|
|
25
25
|
".": {
|
|
26
|
-
"types": "./
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
27
|
"esm2020": "./esm2020/kolektor-nucleus-notifications.mjs",
|
|
28
28
|
"es2020": "./fesm2020/kolektor-nucleus-notifications.mjs",
|
|
29
29
|
"es2015": "./fesm2015/kolektor-nucleus-notifications.mjs",
|