@chat21/chat21-ionic 3.0.55-RC6 → 3.0.57
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/CHANGELOG.md +95 -1
- package/package.json +1 -1
- package/src/app/app.component.scss +1 -0
- package/src/app/app.component.ts +615 -515
- package/src/app/app.module.ts +1 -1
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +2 -1
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +44 -24
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +7 -8
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +9 -7
- package/src/app/chatlib/conversation-detail/message/avatar/avatar.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +22 -14
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +85 -45
- package/src/app/chatlib/conversation-detail/message/buttons/action-button/action-button.component.scss +1 -1
- package/src/app/chatlib/conversation-detail/message/buttons/action-button/action-button.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/buttons/link-button/link-button.component.scss +4 -4
- package/src/app/chatlib/conversation-detail/message/buttons/link-button/link-button.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/buttons/text-button/text-button.component.scss +1 -1
- package/src/app/chatlib/conversation-detail/message/buttons/text-button/text-button.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/frame/frame.component.ts +4 -2
- package/src/app/chatlib/conversation-detail/message/image/image.component.html +9 -8
- package/src/app/chatlib/conversation-detail/message/image/image.component.scss +3 -2
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +35 -3
- package/src/app/chatlib/conversation-detail/message/info-message/info-message.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.html +56 -0
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.scss +169 -0
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.spec.ts +33 -0
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.ts +80 -0
- package/src/app/chatlib/conversation-detail/message/return-receipt/return-receipt.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/text/text.component.html +2 -1
- package/src/app/chatlib/conversation-detail/message/text/text.component.ts +4 -4
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +40 -13
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +147 -1
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +47 -2
- package/src/app/components/authentication/login/login.component.scss +1 -1
- package/src/app/components/contacts-directory/contacts-directory.component.html +3 -2
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +2 -2
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +28 -13
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +1 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +10 -6
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +46 -43
- package/src/app/components/conversation-info/advanced-info-accordion/advanced-info-accordion.component.html +2 -2
- package/src/app/components/conversation-info/info-content/info-content.component.ts +15 -5
- package/src/app/components/conversation-info/info-group/info-group.component.ts +4 -4
- package/src/app/components/utils/avatar-profile/avatar-profile.component.html +2 -1
- package/src/app/components/utils/user-presence/user-presence.component.ts +8 -6
- package/src/app/pages/contacts-directory/contacts-directory.page.ts +1 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.html +4 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +218 -42
- package/src/app/pages/conversations-list/conversations-list.page.html +1 -1
- package/src/app/pages/conversations-list/conversations-list.page.ts +135 -45
- package/src/app/pages/loader-preview/loader-preview.page.html +1 -1
- package/src/app/pages/loader-preview/loader-preview.page.ts +18 -5
- package/src/app/pages/profile-info/profile-info.page.html +2 -0
- package/src/app/services/nav-proxy.service.ts +2 -2
- package/src/app/services/network-service/network.service.spec.ts +12 -0
- package/src/app/services/network-service/network.service.ts +46 -0
- package/src/app/shared/shared.module.ts +2 -0
- package/src/assets/i18n/en.json +4 -2
- package/src/assets/i18n/it.json +5 -3
- package/src/chat21-core/providers/abstract/app-storage.service.ts +2 -2
- package/src/chat21-core/providers/chat-manager.ts +2 -1
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +3 -2
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +112 -69
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +4 -4
- package/src/chat21-core/providers/firebase/firebase-image-repo.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +29 -29
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +1 -0
- package/src/chat21-core/providers/localSessionStorage.ts +155 -154
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +42 -12
- package/src/chat21-core/utils/user-typing/user-typing.component.html +6 -11
- package/src/chat21-core/utils/utils.ts +3 -3
- package/src/global.scss +17 -0
- package/src/index.html +27 -59
|
@@ -33,6 +33,7 @@ import { LoggerService } from '../abstract/logger.service';
|
|
|
33
33
|
import { Observable, Observer, fromEvent, merge } from 'rxjs';
|
|
34
34
|
import { map } from 'rxjs/operators'
|
|
35
35
|
import { Network } from '@ionic-native/network/ngx';
|
|
36
|
+
|
|
36
37
|
// @Injectable({ providedIn: 'root' })
|
|
37
38
|
@Injectable()
|
|
38
39
|
export class FirebaseAuthService extends MessagingAuthService {
|
|
@@ -60,40 +61,58 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
60
61
|
|
|
61
62
|
status = 'ONLINE';
|
|
62
63
|
isConnected = true;
|
|
63
|
-
|
|
64
|
+
unsubscribe: any;
|
|
64
65
|
constructor(
|
|
65
66
|
public http: HttpClient,
|
|
66
67
|
private network: Network,
|
|
67
68
|
private connectionService: ConnectionService
|
|
68
69
|
) {
|
|
69
70
|
super();
|
|
71
|
+
// this.initialize()
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
75
|
*
|
|
74
76
|
*/
|
|
75
77
|
initialize() {
|
|
76
|
-
|
|
78
|
+
console.log('initialize FROM [APP-COMP] [FIREBASEAuthSERVICE]')
|
|
77
79
|
this.SERVER_BASE_URL = this.getBaseUrl();
|
|
78
80
|
this.URL_TILEDESK_CREATE_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'chat21/firebase/auth/createCustomToken';
|
|
79
81
|
this.logger.info('[FIREBASEAuthSERVICE] - initialize URL_TILEDESK_CREATE_CUSTOM_TOKEN ', this.URL_TILEDESK_CREATE_CUSTOM_TOKEN)
|
|
80
|
-
// this.URL_TILEDESK_SIGNIN = this.SERVER_BASE_URL + 'auth/signin';
|
|
81
|
-
// this.URL_TILEDESK_SIGNIN_ANONYMOUSLY = this.SERVER_BASE_URL + 'auth/signinAnonymously'
|
|
82
|
-
// this.URL_TILEDESK_SIGNIN_WITH_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'auth/signinWithCustomToken';
|
|
83
|
-
// this.checkIsAuth();
|
|
84
|
-
|
|
85
|
-
// this.createOnline$().subscribe((isOnline) =>{
|
|
86
|
-
// console.log('FIREBASEAuthSERVICE] isOnline ', isOnline);
|
|
87
|
-
// if (isOnline === true ) {
|
|
88
|
-
// this.onAuthStateChanged();
|
|
89
|
-
// }
|
|
90
|
-
// })
|
|
91
|
-
this.checkInternetConnection()
|
|
92
82
|
|
|
93
|
-
|
|
83
|
+
|
|
84
|
+
let firebasePersistence;
|
|
85
|
+
// console.log('FB-AUTH firebasePersistence', this.getPersistence())
|
|
86
|
+
switch (this.getPersistence()) {
|
|
87
|
+
case 'SESSION': {
|
|
88
|
+
firebasePersistence = firebase.auth.Auth.Persistence.SESSION;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'LOCAL': {
|
|
92
|
+
firebasePersistence = firebase.auth.Auth.Persistence.LOCAL;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case 'NONE': {
|
|
96
|
+
firebasePersistence = firebase.auth.Auth.Persistence.NONE;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
default: {
|
|
100
|
+
firebasePersistence = firebase.auth.Auth.Persistence.NONE;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
firebase.auth().setPersistence(firebasePersistence).then(async () => {
|
|
105
|
+
console.log('[FIREBASEAuthSERVICE] firebasePersistence ', firebasePersistence)
|
|
106
|
+
this.onAuthStateChanged();
|
|
107
|
+
})
|
|
108
|
+
.catch((error) => {
|
|
109
|
+
this.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
|
|
94
113
|
}
|
|
95
114
|
|
|
96
|
-
checkInternetConnection
|
|
115
|
+
checkInternetConnection() {
|
|
97
116
|
this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection');
|
|
98
117
|
// let connectSubscription = this.network.onConnect().subscribe(() => {
|
|
99
118
|
// this.logger.log('[FIREBASEAuthSERVICE] - network connected!');
|
|
@@ -107,28 +126,28 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
107
126
|
// }, 3000);
|
|
108
127
|
// });
|
|
109
128
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
|
|
130
|
+
// this.connectionService.monitor().subscribe(isConnected => {
|
|
131
|
+
// this.isConnected = isConnected;
|
|
132
|
+
// this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection isConnected', isConnected);
|
|
133
|
+
// if (this.isConnected) {
|
|
134
|
+
// this.status = "ONLINE";
|
|
135
|
+
|
|
136
|
+
// // this.onAuthStateChanged();
|
|
137
|
+
// firebase.auth().onAuthStateChanged(user => {
|
|
138
|
+
// this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
|
|
139
|
+
// })
|
|
140
|
+
// }
|
|
141
|
+
// else {
|
|
142
|
+
// this.status = "OFFLINE";
|
|
143
|
+
// // this.onAuthStateChanged();
|
|
144
|
+
// firebase.auth().onAuthStateChanged(user => {
|
|
145
|
+
// this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
|
|
146
|
+
// })
|
|
147
|
+
// }
|
|
148
|
+
// })
|
|
149
|
+
|
|
150
|
+
|
|
132
151
|
}
|
|
133
152
|
|
|
134
153
|
// createOnline$() {
|
|
@@ -178,16 +197,37 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
178
197
|
*/
|
|
179
198
|
onAuthStateChanged() {
|
|
180
199
|
const that = this;
|
|
181
|
-
|
|
182
|
-
|
|
200
|
+
|
|
201
|
+
// ---------------------------------------------------------------------------------------------------
|
|
202
|
+
// Protecting from multiple subsciptions due to multiple app initializations (call to initializeApp())
|
|
203
|
+
// Only one subscriber x application allowed
|
|
204
|
+
// ---------------------------------------------------------------------------------------------------
|
|
205
|
+
if (this.unsubscribe) {
|
|
206
|
+
console.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged ALREADY SUBSCRIBED')
|
|
207
|
+
return
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
this.unsubscribe = firebase.auth().onAuthStateChanged(user => {
|
|
211
|
+
console.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged', user)
|
|
183
212
|
if (!user) {
|
|
184
213
|
this.logger.log('[FIREBASEAuthSERVICE] 1 - PASSO OFFLINE AL CHAT MANAGER')
|
|
214
|
+
// this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged user ', user)
|
|
215
|
+
|
|
185
216
|
that.BSAuthStateChanged.next('offline');
|
|
217
|
+
// console.log('initialize FROM [APP-COMP] that.BSAuthStateChanged ', that.BSAuthStateChanged)
|
|
186
218
|
} else {
|
|
187
219
|
this.logger.log('[FIREBASEAuthSERVICE] 2 - PASSO ONLINE AL CHAT MANAGER')
|
|
220
|
+
// this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged user ', user)
|
|
188
221
|
that.BSAuthStateChanged.next('online');
|
|
189
222
|
}
|
|
223
|
+
}, error => {
|
|
224
|
+
this.logger.error('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged * error * ', error)
|
|
225
|
+
}, () => {
|
|
226
|
+
this.logger.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged *** complete *** ');
|
|
227
|
+
|
|
190
228
|
});
|
|
229
|
+
|
|
230
|
+
|
|
191
231
|
}
|
|
192
232
|
|
|
193
233
|
/**
|
|
@@ -195,36 +235,34 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
195
235
|
* @param token
|
|
196
236
|
*/
|
|
197
237
|
signInFirebaseWithCustomToken(token: string): Promise<any> {
|
|
198
|
-
const that = this;
|
|
199
|
-
let firebasePersistence;
|
|
200
|
-
console.log('FB-AUTH firebasePersistence', this.getPersistence())
|
|
201
|
-
switch (this.getPersistence()) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
return firebase.auth().setPersistence(firebasePersistence).then(async () => {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
|
|
224
|
-
// that.firebaseSignInWithCustomToken.next(null);
|
|
225
|
-
});
|
|
238
|
+
// const that = this;
|
|
239
|
+
// let firebasePersistence;
|
|
240
|
+
// // console.log('FB-AUTH firebasePersistence', this.getPersistence())
|
|
241
|
+
// switch (this.getPersistence()) {
|
|
242
|
+
// case 'SESSION': {
|
|
243
|
+
// firebasePersistence = firebase.auth.Auth.Persistence.SESSION;
|
|
244
|
+
// break;
|
|
245
|
+
// }
|
|
246
|
+
// case 'LOCAL': {
|
|
247
|
+
// firebasePersistence = firebase.auth.Auth.Persistence.LOCAL;
|
|
248
|
+
// break;
|
|
249
|
+
// }
|
|
250
|
+
// case 'NONE': {
|
|
251
|
+
// firebasePersistence = firebase.auth.Auth.Persistence.NONE;
|
|
252
|
+
// break;
|
|
253
|
+
// }
|
|
254
|
+
// default: {
|
|
255
|
+
// firebasePersistence = firebase.auth.Auth.Persistence.NONE;
|
|
256
|
+
// break;
|
|
257
|
+
// }
|
|
258
|
+
// }
|
|
259
|
+
// return firebase.auth().setPersistence(firebasePersistence).then(async () => {
|
|
260
|
+
return firebase.auth().signInWithCustomToken(token).then(async (user) => {
|
|
261
|
+
|
|
262
|
+
// that.firebaseSignInWithCustomToken.next(response);
|
|
226
263
|
}).catch((error) => {
|
|
227
|
-
|
|
264
|
+
this.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
|
|
265
|
+
// that.firebaseSignInWithCustomToken.next(null);
|
|
228
266
|
});
|
|
229
267
|
}
|
|
230
268
|
|
|
@@ -271,6 +309,8 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
271
309
|
// cancello token
|
|
272
310
|
// this.appStorage.removeItem('tiledeskToken');
|
|
273
311
|
//localStorage.removeItem('firebaseToken');
|
|
312
|
+
|
|
313
|
+
|
|
274
314
|
that.BSSignOut.next(true);
|
|
275
315
|
}).catch((error) => {
|
|
276
316
|
that.logger.error('[FIREBASEAuthSERVICE] signOut error: ', error);
|
|
@@ -317,9 +357,12 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
317
357
|
|
|
318
358
|
logout() {
|
|
319
359
|
this.logger.log('[FIREBASEAuthSERVICE] logout');
|
|
360
|
+
this.BSAuthStateChanged.next(null);
|
|
361
|
+
|
|
320
362
|
// cancello token firebase dal local storage e da firebase
|
|
321
363
|
// dovrebbe scattare l'evento authchangeStat
|
|
322
364
|
this.signOut();
|
|
365
|
+
// this.unsubscribe();
|
|
323
366
|
}
|
|
324
367
|
|
|
325
368
|
}
|
|
@@ -217,7 +217,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
217
217
|
|
|
218
218
|
this.getFirebaseToken((error, idToken) => {
|
|
219
219
|
this.logger.debug('[FIREBASEConversationsHandlerSERVICE] DELETE CONV idToken', idToken)
|
|
220
|
-
this.logger.
|
|
220
|
+
this.logger.debug('F[FIREBASEConversationsHandlerSERVICE] DELETE CONV error', error)
|
|
221
221
|
if (idToken) {
|
|
222
222
|
const httpOptions = {
|
|
223
223
|
headers: new HttpHeaders({
|
|
@@ -282,8 +282,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
282
282
|
this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot.val() *****', childSnapshot.val());
|
|
283
283
|
this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot *****', childSnapshot)
|
|
284
284
|
// && childData.uid
|
|
285
|
-
if (childSnapshot && childSnapshot.key) {
|
|
286
|
-
// if (childData) {
|
|
285
|
+
if (childSnapshot && childSnapshot.key && childData) {
|
|
287
286
|
childData.uid = childSnapshot.key;
|
|
288
287
|
const conversation = this.completeConversation(childData);
|
|
289
288
|
if (conversation) {
|
|
@@ -291,6 +290,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
291
290
|
} else {
|
|
292
291
|
callback(null)
|
|
293
292
|
}
|
|
293
|
+
|
|
294
294
|
}
|
|
295
295
|
// this.BSConversationDetail.next(conversation);
|
|
296
296
|
});
|
|
@@ -400,7 +400,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
|
|
|
400
400
|
this.conversationAdded.next(conversationAdded);
|
|
401
401
|
}
|
|
402
402
|
} else {
|
|
403
|
-
this.logger.
|
|
403
|
+
this.logger.log('[FIREBASEConversationsHandlerSERVICE]ADDED::conversations with conversationId: ', childSnapshot.key, 'is not valid')
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
|
|
@@ -27,7 +27,7 @@ export class FirebaseImageRepoService extends ImageRepoService {
|
|
|
27
27
|
getImagePhotoUrl(uid: string): string {
|
|
28
28
|
this.baseImageURL = this.getImageBaseUrl()
|
|
29
29
|
let sender_id = '';
|
|
30
|
-
if (uid.includes('bot_')) {
|
|
30
|
+
if (uid && uid.includes('bot_')) {
|
|
31
31
|
sender_id = uid.slice(4)
|
|
32
32
|
} else {
|
|
33
33
|
sender_id = uid
|
|
@@ -39,10 +39,10 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
39
39
|
navigator.serviceWorker.getRegistrations().then((serviceWorkerRegistrations) => {
|
|
40
40
|
this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser serviceWorkerRegistrations", serviceWorkerRegistrations)
|
|
41
41
|
if (serviceWorkerRegistrations.length > 0) {
|
|
42
|
-
serviceWorkerRegistrations.forEach(
|
|
43
|
-
|
|
44
|
-
this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations scriptURL", registrations.active.scriptURL)
|
|
45
|
-
this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations state", registrations.active.state)
|
|
42
|
+
serviceWorkerRegistrations.forEach(registration => {
|
|
43
|
+
this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registration ", registration)
|
|
44
|
+
// this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations scriptURL", registrations.active.scriptURL)
|
|
45
|
+
// this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations state", registrations.active.state)
|
|
46
46
|
|
|
47
47
|
});
|
|
48
48
|
} else {
|
|
@@ -63,10 +63,10 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
63
63
|
|
|
64
64
|
getNotificationPermissionAndSaveToken(currentUserUid) {
|
|
65
65
|
// this.tenant = this.getTenant();
|
|
66
|
-
this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - tenant ', this.tenant)
|
|
67
|
-
this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - currentUserUid ', currentUserUid)
|
|
66
|
+
this.logger.log('initialize FROM [APP-COMP] - [FIREBASE-NOTIFICATIONS] calling requestPermission - tenant ', this.tenant, ' currentUserUid ', currentUserUid)
|
|
67
|
+
// this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - currentUserUid ', currentUserUid)
|
|
68
68
|
this.userId = currentUserUid;
|
|
69
|
-
// Service Worker explicit registration to explicitly define sw location at a path
|
|
69
|
+
// Service Worker explicit registration to explicitly define sw location at a path,
|
|
70
70
|
// const swRegistration = async () => {
|
|
71
71
|
// try {
|
|
72
72
|
// await navigator.serviceWorker.register('http://localhost:8101/firebase-messaging-sw.js');
|
|
@@ -76,8 +76,9 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
76
76
|
// }
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
if (firebase.messaging.isSupported()) {
|
|
81
|
+
const messaging = firebase.messaging();
|
|
81
82
|
// messaging.requestPermission()
|
|
82
83
|
Notification.requestPermission().then((permission) => {
|
|
83
84
|
if (permission === 'granted') {
|
|
@@ -156,39 +157,38 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
156
157
|
|
|
157
158
|
removeNotificationsInstance(callback: (string) => void) {
|
|
158
159
|
var self = this;
|
|
159
|
-
firebase.auth().onAuthStateChanged(function (user) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const connectionsRefinstancesId = urlNodeFirebase + '/users/' + this.userId + '/instances/'
|
|
173
|
-
this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
|
|
160
|
+
// firebase.auth().onAuthStateChanged(function (user) {
|
|
161
|
+
// if (user) {
|
|
162
|
+
// self.logger.debug('[FIREBASE-NOTIFICATIONS] - FB User is signed in. ', user)
|
|
163
|
+
// self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.userId', self.userId);
|
|
164
|
+
// self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > FCMcurrentToken', self.FCMcurrentToken);
|
|
165
|
+
// // this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > this.tenant', this.tenant);
|
|
166
|
+
// } else {
|
|
167
|
+
// self.logger.debug('[FIREBASE-NOTIFICATIONS] - No FB user is signed in. ', user)
|
|
168
|
+
// }
|
|
169
|
+
// });
|
|
170
|
+
const urlNodeFirebase = '/apps/' + self.tenant
|
|
171
|
+
const connectionsRefinstancesId = urlNodeFirebase + '/users/' + self.userId + '/instances/'
|
|
172
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
|
|
174
173
|
let connectionsRefURL = '';
|
|
175
174
|
if (connectionsRefinstancesId) {
|
|
176
|
-
connectionsRefURL = connectionsRefinstancesId +
|
|
175
|
+
connectionsRefURL = connectionsRefinstancesId + self.FCMcurrentToken;
|
|
177
176
|
const connectionsRef = firebase.database().ref().child(connectionsRefURL);
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef ', connectionsRef);
|
|
178
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef url ', connectionsRefURL);
|
|
180
179
|
connectionsRef.off()
|
|
181
180
|
connectionsRef.remove()
|
|
182
181
|
.then(() => {
|
|
183
|
-
|
|
182
|
+
self.logger.log("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance > Remove succeeded.")
|
|
184
183
|
callback('success')
|
|
185
184
|
}).catch((error) => {
|
|
186
|
-
|
|
185
|
+
self.logger.error("[FIREBASE-NOTIFICATIONS] >>>> removeNotificationsInstance Remove failed: " + error.message)
|
|
187
186
|
callback('error')
|
|
188
187
|
}).finally(() => {
|
|
189
|
-
|
|
188
|
+
self.logger.log('[FIREBASE-NOTIFICATIONS] COMPLETED');
|
|
190
189
|
})
|
|
191
190
|
}
|
|
191
|
+
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// removeNotificationsInstance() {
|
|
@@ -129,6 +129,7 @@ export class FirebasePresenceService extends PresenceService {
|
|
|
129
129
|
* @param userid
|
|
130
130
|
*/
|
|
131
131
|
public setPresence(userid: string): void {
|
|
132
|
+
this.logger.info('initialize FROM [APP-COMP] - [FIREBASEPresenceSERVICE] - SET PRESENCE userid ', userid)
|
|
132
133
|
this.onlineConnectionsRef = this.referenceOnlineForUser(userid);
|
|
133
134
|
this.lastOnlineConnectionsRef = this.referenceLastOnlineForUser(userid);
|
|
134
135
|
const connectedRefURL = '/.info/connected';
|