mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
fix publication
This commit is contained in:
@@ -116,29 +116,29 @@ export class NotificationsService {
|
||||
|
||||
if (this.platform.is('mobile')) {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
tracing.setAttribute('notification.available', 'false')
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('notification.available', 'false')
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
return false
|
||||
}
|
||||
if (this.platform.is('ios')) {
|
||||
FCM.getToken()
|
||||
.then(r => {
|
||||
tracing.setAttribute('notification.token', 'true')
|
||||
tracing?.setAttribute('notification.token', 'true')
|
||||
this.postToken(r.token, geturl, tracing)
|
||||
this.token = r.token
|
||||
// alert(this.token)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
tracing.setAttribute('notification.token', 'false')
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('notification.token', 'false')
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
});
|
||||
} else {
|
||||
|
||||
PushNotifications.addListener('registration',
|
||||
(token: Token) => {
|
||||
|
||||
tracing.setAttribute('notification.token', 'true')
|
||||
tracing?.setAttribute('notification.token', 'true')
|
||||
this.postToken(token.value, geturl, tracing)
|
||||
this.token = token.value
|
||||
|
||||
@@ -147,19 +147,19 @@ export class NotificationsService {
|
||||
}
|
||||
|
||||
} else {
|
||||
tracing.setAttribute('notification.request', 'true')
|
||||
tracing?.setAttribute('notification.request', 'true')
|
||||
this.afMessaging.requestToken.subscribe(
|
||||
(token) => {
|
||||
// Save the token to your server for sending notifications
|
||||
console.log('Permission granted! Token:', token);
|
||||
this.postToken(token, geturl, tracing)
|
||||
this.token = token
|
||||
tracing.setAttribute('notification.token', 'true')
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
tracing?.setAttribute('notification.token', 'true')
|
||||
tracing?.setAttribute('outcome', 'success')
|
||||
},
|
||||
(error) => {
|
||||
|
||||
tracing.setAttribute('notification.token', 'false')
|
||||
|
||||
tracing?.setAttribute('notification.token', 'false')
|
||||
tracing.hasError('Permission denied: request token');
|
||||
}
|
||||
);
|
||||
@@ -173,7 +173,7 @@ export class NotificationsService {
|
||||
|
||||
this.DeleteToken(geturl)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
postToken(token, geturl, tracing: TracingType) {
|
||||
@@ -185,14 +185,14 @@ export class NotificationsService {
|
||||
Service: 1
|
||||
};
|
||||
|
||||
tracing.setAttribute('token.data', token)
|
||||
tracing?.setAttribute('token.data', token)
|
||||
this.http.post<Tokenn>(`${geturl}`, body, { }).subscribe(data => {
|
||||
this.active = true
|
||||
tracing.setAttribute('outcome','success')
|
||||
tracing?.setAttribute('outcome','success')
|
||||
tracing.finish()
|
||||
}, (error) => {
|
||||
tracing.setAttribute('postToken','failed')
|
||||
tracing.setAttribute('outcome','failed')
|
||||
tracing?.setAttribute('postToken','failed')
|
||||
tracing?.setAttribute('outcome','failed')
|
||||
tracing.finish()
|
||||
})
|
||||
}
|
||||
@@ -493,9 +493,9 @@ export class NotificationsService {
|
||||
this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras));
|
||||
}, 200);
|
||||
} else {
|
||||
tracing.setAttribute('notification.route', 'false')
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.setAttribute('parameters', JSON.stringify(notification))
|
||||
tracing?.setAttribute('notification.route', 'false')
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('parameters', JSON.stringify(notification))
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -504,12 +504,12 @@ export class NotificationsService {
|
||||
if(!validationError.success) {
|
||||
const errors: z.ZodError<any> = (validationError as any).error;
|
||||
console.log("Validation errors:", errors.issues);
|
||||
tracing.setAttribute('validation.errors', JSON.stringify(errors.issues))
|
||||
tracing?.setAttribute('validation.errors', JSON.stringify(errors.issues))
|
||||
}
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.setAttribute('parameters', JSON.stringify(notification))
|
||||
tracing.setAttribute('error', JSON.stringify(error))
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('parameters', JSON.stringify(notification))
|
||||
tracing?.setAttribute('error', JSON.stringify(error))
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user