mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Improve responsiveness and add doc to task
This commit is contained in:
@@ -4,7 +4,7 @@ import { environment } from 'src/environments/environment';
|
||||
import { StorageService } from 'src/app/services/storage.service';
|
||||
import { AuthConnstants } from 'src/app/config/auth-constants';
|
||||
import { Token } from '../models/token.model';
|
||||
import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
|
||||
// import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
|
||||
/* import { AgendaPage } from '../pages/agenda/agenda.page'
|
||||
import { ExpedientePage } from '../pages/gabinete-digital/expediente/expediente.page'
|
||||
import { EventListPage } from '../pages/gabinete-digital/event-list/event-list.page';
|
||||
@@ -27,7 +27,7 @@ export class NotificationsService {
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private fcm: FCM,
|
||||
// private fcm: FCM,
|
||||
private storageService: StorageService,
|
||||
private modalController: ModalController,
|
||||
public modalCtrl: AlertController,
|
||||
@@ -45,71 +45,71 @@ export class NotificationsService {
|
||||
return this.http.get<Token[]>(`${geturl}`);
|
||||
}
|
||||
|
||||
getAndpostToken(username) {
|
||||
if(this.platform.is('desktop')) {
|
||||
console.log('Notifications not supported')
|
||||
} else {
|
||||
// getAndpostToken(username) {
|
||||
// if(this.platform.is('desktop')) {
|
||||
// console.log('Notifications not supported')
|
||||
// } else {
|
||||
|
||||
const geturl = environment.apiURL + 'notifications/token';
|
||||
// const geturl = environment.apiURL + 'notifications/token';
|
||||
|
||||
return this.fcm.getToken().then(token => {
|
||||
console.log('token: ', token)
|
||||
this.storageService.store(username, token);
|
||||
this.storageService.get(username).then(value => {
|
||||
console.log('STORAGE TOKEN', value)
|
||||
this.storageService.get(AuthConnstants.USER).then(res => {
|
||||
console.log('USERID', res);
|
||||
const headers = { 'Authorization': 'Basic cGF1bG8ucGludG9AZ2FiaW5ldGVkaWdpdGFsLmxvY2FsOnRhYnRlc3RlQDAwNg==' };
|
||||
const body = {
|
||||
UserId: res.UserId,
|
||||
TokenId: token,
|
||||
Status: 1,
|
||||
Service: 1
|
||||
};
|
||||
// return this.fcm.getToken().then(token => {
|
||||
// console.log('token: ', token)
|
||||
// this.storageService.store(username, token);
|
||||
// this.storageService.get(username).then(value => {
|
||||
// console.log('STORAGE TOKEN', value)
|
||||
// this.storageService.get(AuthConnstants.USER).then(res => {
|
||||
// console.log('USERID', res);
|
||||
// const headers = { 'Authorization': 'Basic cGF1bG8ucGludG9AZ2FiaW5ldGVkaWdpdGFsLmxvY2FsOnRhYnRlc3RlQDAwNg==' };
|
||||
// const body = {
|
||||
// UserId: res.UserId,
|
||||
// TokenId: token,
|
||||
// Status: 1,
|
||||
// Service: 1
|
||||
// };
|
||||
|
||||
this.http.post<Token>(`${geturl}`, body, { headers }).subscribe(data => {
|
||||
console.log('TOKEN USER MIDLE', data);
|
||||
})
|
||||
});
|
||||
// this.http.post<Token>(`${geturl}`, body, { headers }).subscribe(data => {
|
||||
// console.log('TOKEN USER MIDLE', data);
|
||||
// })
|
||||
// });
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
async onReceviNotification(viewEventDetail, viewExpedientDetail, openApproveModal, viewPublications, viewPublicationDetail) {
|
||||
this.fcm.onNotification().subscribe(data => {
|
||||
if (data.click_action) {
|
||||
console.log("Received in background: ", data);
|
||||
// this.fcm.onNotification().subscribe(data => {
|
||||
// if (data.click_action) {
|
||||
// console.log("Received in background: ", data);
|
||||
|
||||
if (data.Service === "agenda") {
|
||||
viewEventDetail(data.IdObject)
|
||||
}
|
||||
else if (data.Service === "gabinete-digital" && data.Object === "expediente") {
|
||||
console.log('expediante 1')
|
||||
viewExpedientDetail(data.IdObject)
|
||||
}
|
||||
else if (data.Service === "gabinete-digital" && data.Object === "event-list") {
|
||||
openApproveModal(data.IdObject);
|
||||
}
|
||||
else if (data.Service === "accoes" && data.Object === "accao") {
|
||||
viewPublications(data.IdObject)
|
||||
}
|
||||
else if (data.Service === "accoes" && data.Object === "publicacao") {
|
||||
viewPublicationDetail(data.IdObject)
|
||||
}
|
||||
// if (data.Service === "agenda") {
|
||||
// viewEventDetail(data.IdObject)
|
||||
// }
|
||||
// else if (data.Service === "gabinete-digital" && data.Object === "expediente") {
|
||||
// console.log('expediante 1')
|
||||
// viewExpedientDetail(data.IdObject)
|
||||
// }
|
||||
// else if (data.Service === "gabinete-digital" && data.Object === "event-list") {
|
||||
// openApproveModal(data.IdObject);
|
||||
// }
|
||||
// else if (data.Service === "accoes" && data.Object === "accao") {
|
||||
// viewPublications(data.IdObject)
|
||||
// }
|
||||
// else if (data.Service === "accoes" && data.Object === "publicacao") {
|
||||
// viewPublicationDetail(data.IdObject)
|
||||
// }
|
||||
|
||||
} /* else {
|
||||
console.log("Received in foreground: ", data);
|
||||
// } /* else {
|
||||
// console.log("Received in foreground: ", data);
|
||||
|
||||
console.log(data.Service)
|
||||
console.log(data.Object)
|
||||
console.log(data.IdObject)
|
||||
this.openApproveModal(data.IdObject);
|
||||
// console.log(data.Service)
|
||||
// console.log(data.Object)
|
||||
// console.log(data.IdObject)
|
||||
// this.openApproveModal(data.IdObject);
|
||||
|
||||
}; */
|
||||
});
|
||||
// }; */
|
||||
// });
|
||||
}
|
||||
|
||||
platformVerify() {
|
||||
|
||||
Reference in New Issue
Block a user