mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { SessionStore } from 'src/app/store/session.service';
|
|
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class NotificationsTriggerService {
|
|
|
|
constructor(
|
|
private http: HttpClient,
|
|
) { }
|
|
|
|
|
|
|
|
|
|
sendNotificationWithSend(userID, title, bodymsg, roomId) {
|
|
const geturl = environment.apiURL + `notifications/send`;
|
|
|
|
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
|
const message = {
|
|
"Service": "chat",
|
|
"IdObject": roomId
|
|
}
|
|
let id = 437
|
|
this.http.post<Token>(geturl + `?userId=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
|
|
|
|
}, (error) => {
|
|
|
|
})
|
|
}
|
|
|
|
|
|
ChatSendMessageNotification(userID, title, bodymsg, roomId) {
|
|
const geturl = environment.apiURL + `notifications/sendbyUsername`;
|
|
|
|
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
|
const message = {
|
|
"Service": "chat",
|
|
"IdObject": roomId
|
|
}
|
|
let id = 437
|
|
this.http.post<Token>(geturl + `?username=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
|
|
// this.active = true
|
|
}, (error) => {
|
|
|
|
})
|
|
}
|
|
|
|
ChatSendMessageNotificationGrup(usersID, title, bodymsg, roomId) {
|
|
const geturl = environment.apiURL + `notifications/sendByUsernames`;
|
|
|
|
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
|
const message = {
|
|
"Users": usersID,
|
|
"NotificationData": {
|
|
"Service": "chat",
|
|
"IdObject": roomId
|
|
}
|
|
}
|
|
|
|
this.http.post<Token>(geturl + `?title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
|
|
// this.active = true
|
|
}, (error) => {
|
|
|
|
})
|
|
}
|
|
}
|