mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix ubgs
This commit is contained in:
@@ -34,6 +34,7 @@ export class NotificationsService {
|
||||
active = false
|
||||
isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
|
||||
notificationReceived: EventEmitter<void> = new EventEmitter<void>();
|
||||
token = ''
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
@@ -81,6 +82,7 @@ export class NotificationsService {
|
||||
PushNotifications.addListener('registration',
|
||||
(token: Token) => {
|
||||
this.postToken(token.value, geturl)
|
||||
this.token = token.value
|
||||
}
|
||||
);
|
||||
} else {
|
||||
@@ -89,6 +91,7 @@ export class NotificationsService {
|
||||
// Save the token to your server for sending notifications
|
||||
console.log('Permission granted! Token:', token);
|
||||
this.postToken(token, geturl)
|
||||
this.token = token
|
||||
},
|
||||
(error) => {
|
||||
console.error('Permission denied:', error);
|
||||
@@ -98,6 +101,13 @@ export class NotificationsService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
DeletePostToken() {
|
||||
const geturl = environment.apiURL + `notifications/token?userId=${SessionStore.user.UserId}&tokenId=${this.token}`;
|
||||
|
||||
this.DeleteToken(geturl)
|
||||
}
|
||||
|
||||
postToken(token, geturl) {
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const body = {
|
||||
@@ -113,6 +123,19 @@ export class NotificationsService {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
DeleteToken(geturl) {
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const body = {};
|
||||
|
||||
this.http.delete<Tokenn>(`${geturl}`, { headers, body }).subscribe(data => {
|
||||
this.active = true
|
||||
}, (error) => {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
registrationError() {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
@@ -137,8 +160,8 @@ export class NotificationsService {
|
||||
this.active = true
|
||||
console.log('NOtification Listener', notification)
|
||||
this.storenotification(notification)
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@@ -154,7 +177,7 @@ export class NotificationsService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
storenotification(notification) {
|
||||
console.log('Store Notification ',notification)
|
||||
this.storageService.get("Notifications").then((store) => {
|
||||
@@ -168,21 +191,21 @@ export class NotificationsService {
|
||||
let exists = accumulator.find(item => {
|
||||
return item.id === current.id;
|
||||
});
|
||||
|
||||
if(!exists) {
|
||||
|
||||
if(!exists) {
|
||||
accumulator = accumulator.concat(current);
|
||||
}
|
||||
return accumulator;
|
||||
}, []);
|
||||
|
||||
|
||||
console.log('Notification Result',result);
|
||||
this.storageService.store("Notifications", result).then(() => {
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
this.storageService.store("Notifications", store).then(() => {
|
||||
this.eventtrigger.publishSomeData({
|
||||
@@ -190,11 +213,6 @@ export class NotificationsService {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}).catch((error) => {
|
||||
if (!error) {
|
||||
this.storageService.store("Notifications", [notification])
|
||||
@@ -208,13 +226,13 @@ export class NotificationsService {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
PushNotifications.addListener('pushNotificationActionPerformed',
|
||||
(notification: ActionPerformed) => {
|
||||
this.active = true
|
||||
console.log('NOtification Listener Backgroud', notification)
|
||||
/* this.DataArray.push(notification.notification)
|
||||
|
||||
|
||||
this.storageService.store("Notifications", this.DataArray)
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
@@ -236,7 +254,7 @@ export class NotificationsService {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
sendNotificationWithSend(userID, title, bodymsg, roomId) {
|
||||
@@ -254,7 +272,7 @@ export class NotificationsService {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
ChatSendMessageNotification(userID, title, bodymsg, roomId) {
|
||||
const geturl = environment.apiURL + `notifications/sendbyUsername`;
|
||||
@@ -298,7 +316,7 @@ export class NotificationsService {
|
||||
|
||||
notificatinsRoutes = (notification) => {
|
||||
|
||||
console.log('BACK BACK',notification)
|
||||
console.log('BACK BACK',notification)
|
||||
|
||||
if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user