mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Notifications back online
This commit is contained in:
@@ -86,86 +86,86 @@ export class NotificationsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
requestPermissions() {
|
requestPermissions() {
|
||||||
// PushNotifications.requestPermissions().then(result => {
|
PushNotifications.requestPermissions().then(result => {
|
||||||
// if (result.receive === 'granted') {
|
if (result.receive === 'granted') {
|
||||||
// // Register with Apple / Google to receive push via APNS/FCM
|
// Register with Apple / Google to receive push via APNS/FCM
|
||||||
// PushNotifications.register();
|
PushNotifications.register();
|
||||||
// } else {
|
} else {
|
||||||
// // Show some error
|
// Show some error
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getAndpostToken(username) {
|
getAndpostToken(username) {
|
||||||
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||||
// console.log('Notifications not supported')
|
console.log('Notifications not supported')
|
||||||
// } else {
|
} else {
|
||||||
// const geturl = environment.apiURL + 'notifications/token';
|
const geturl = environment.apiURL + 'notifications/token';
|
||||||
// PushNotifications.addListener('registration',
|
PushNotifications.addListener('registration',
|
||||||
// (token: Token) => {
|
(token: Token) => {
|
||||||
// console.log('token: ', token.value)
|
console.log('token: ', token.value)
|
||||||
// this.storageService.store(username, token.value);
|
this.storageService.store(username, token.value);
|
||||||
// this.storageService.get(username).then(value => {
|
this.storageService.get(username).then(value => {
|
||||||
// console.log('STORAGE TOKEN', value)
|
console.log('STORAGE TOKEN', value)
|
||||||
// this.storageService.get(AuthConnstants.USER).then(res => {
|
this.storageService.get(AuthConnstants.USER).then(res => {
|
||||||
// console.log('USERID', res);
|
console.log('USERID', res);
|
||||||
// const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||||
// const body = {
|
const body = {
|
||||||
// UserId: res.UserId,
|
UserId: res.UserId,
|
||||||
// TokenId: token.value,
|
TokenId: token.value,
|
||||||
// Status: 1,
|
Status: 1,
|
||||||
// Service: 1
|
Service: 1
|
||||||
// };
|
};
|
||||||
|
|
||||||
// this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
|
this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
|
||||||
// console.log('TOKEN USER MIDLE', data);
|
console.log('TOKEN USER MIDLE', data);
|
||||||
// }, (error) => {
|
}, (error) => {
|
||||||
// console.log('Post token to backend', error)
|
console.log('Post token to backend', error)
|
||||||
// })
|
})
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registrationError() {
|
registrationError() {
|
||||||
// PushNotifications.addListener('registrationError',
|
PushNotifications.addListener('registrationError',
|
||||||
// (error: any) => {
|
(error: any) => {
|
||||||
// console.log('Error on registration: ' + JSON.stringify(error));
|
console.log('Error on registration: ' + JSON.stringify(error));
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onReciveForeground() {
|
onReciveForeground() {
|
||||||
// PushNotifications.addListener('pushNotificationReceived',
|
PushNotifications.addListener('pushNotificationReceived',
|
||||||
// (notification: PushNotificationSchema) => {
|
(notification: PushNotificationSchema) => {
|
||||||
// console.log('Push received: ' + JSON.stringify(notification));
|
console.log('Push received: ' + JSON.stringify(notification));
|
||||||
// this.DataArray.push(notification)
|
this.DataArray.push(notification)
|
||||||
// console.log("On ReceiveNotification", this.DataArray)
|
console.log("On ReceiveNotification", this.DataArray)
|
||||||
// this.storageService.store("Notifications", this.DataArray)
|
this.storageService.store("Notifications", this.DataArray)
|
||||||
// this.eventtrigger.publishSomeData({
|
this.eventtrigger.publishSomeData({
|
||||||
// notification: "recive"
|
notification: "recive"
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onReciveBackground() {
|
onReciveBackground() {
|
||||||
// PushNotifications.addListener('pushNotificationActionPerformed',
|
PushNotifications.addListener('pushNotificationActionPerformed',
|
||||||
// (notification: ActionPerformed) => {
|
(notification: ActionPerformed) => {
|
||||||
// console.log('Push action performed: ' + JSON.stringify(notification));
|
console.log('Push action performed: ' + JSON.stringify(notification));
|
||||||
// /* this.DataArray.push(notification.notification)
|
/* this.DataArray.push(notification.notification)
|
||||||
// console.log("On ReceiveNotification", this.DataArray)
|
console.log("On ReceiveNotification", this.DataArray)
|
||||||
// this.storageService.store("Notifications", this.DataArray)
|
this.storageService.store("Notifications", this.DataArray)
|
||||||
// this.eventtrigger.publishSomeData({
|
this.eventtrigger.publishSomeData({
|
||||||
// notification: "recive"
|
notification: "recive"
|
||||||
// }) */
|
}) */
|
||||||
// this.notificatinsRoutes(notification)
|
this.notificatinsRoutes(notification)
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
tempClearArray() {
|
tempClearArray() {
|
||||||
@@ -175,51 +175,51 @@ export class NotificationsService {
|
|||||||
|
|
||||||
notificatinsRoutes = (notification) => {
|
notificatinsRoutes = (notification) => {
|
||||||
|
|
||||||
// console.log('Push action performed 2222: ' + JSON.stringify(notification.data));
|
console.log('Push action performed 2222: ' + JSON.stringify(notification.data));
|
||||||
|
|
||||||
// if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) {
|
if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) {
|
||||||
// console.log("Id Lenght", notification.notification.data.IdObject.length)
|
console.log("Id Lenght", notification.notification.data.IdObject.length)
|
||||||
// this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.IdObject, 'agenda']));
|
this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.IdObject, 'agenda']));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expediente") {
|
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expediente") {
|
||||||
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.IdObject, 'gabinete-digital']));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "agenda" && notification.notification.data.Object === "event-list") {
|
else if (notification.notification.data.Service === "agenda" && notification.notification.data.Object === "event-list") {
|
||||||
// //this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda']));
|
//this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda']));
|
||||||
// this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.notification.data.IdObject, 'agenda']));
|
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.notification.data.IdObject, 'agenda']));
|
||||||
|
|
||||||
// } else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos") {
|
} else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos") {
|
||||||
|
|
||||||
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.notification.data.IdObject, 'gabinete-digital'], { replaceUrl: true }));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.notification.data.IdObject, 'gabinete-digital'], { replaceUrl: true }));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "parecer") {
|
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "parecer") {
|
||||||
|
|
||||||
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "deferimento") {
|
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "deferimento") {
|
||||||
|
|
||||||
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos-pr") {
|
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos-pr") {
|
||||||
|
|
||||||
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.notification.data.IdObject, 'gabinete-digital']));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "accao") {
|
else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "accao") {
|
||||||
// this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject]));
|
this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject]));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "publicacao") {
|
else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "publicacao") {
|
||||||
// this.zone.run(() => this.router.navigate(['/home/publications/view-publications', notification.notification.data.FolderId, notification.data.IdObject]));
|
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', notification.notification.data.FolderId, notification.data.IdObject]));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas") {
|
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas") {
|
||||||
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital']));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas-assinar") {
|
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas-assinar") {
|
||||||
|
|
||||||
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', notification.notification.data.IdObject, 'gabinete-digital']));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||||
// }
|
}
|
||||||
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes-pr") {
|
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes-pr") {
|
||||||
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital']));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user