Change action click with wasTapped

This commit is contained in:
Eudes Inácio
2021-04-12 15:39:44 +01:00
parent cb9b7b4413
commit e67d63358e
2 changed files with 71 additions and 49 deletions
+42 -34
View File
@@ -4,7 +4,7 @@ import { EventsService } from '../services/events.service';
import { Event } from '../models/event.model';
import { ProcessesService } from '../services/processes.service';
import { NotificationsService } from '../services/notifications.service';
import { ModalController, AlertController, AnimationController } from '@ionic/angular';
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
//import { AlertController } from 'ionic-angular';
/* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core'; */
import { Router } from '@angular/router';
@@ -61,7 +61,8 @@ export class HomePage implements OnInit {
public modalCtrl: AlertController,
private fcm: FCM,
private animationController: AnimationController,
private notificatinsservice: NotificationsService,) {
private notificatinsservice: NotificationsService,
private platform: Platform) {
router.events.subscribe((val) => {
document.querySelectorAll('ion-modal').forEach((e) => e.remove())
@@ -105,40 +106,47 @@ export class HomePage implements OnInit {
}
pushCordova() {
this.fcm.onNotification().subscribe(data => {
this.viewEventDetail(data.IdObject)
if (data.wasTapped) {
console.log("Received in background: ", data);
if(this.platform.is('desktop')) {
console.log('Notifications not supported')
} else {
if (data.Service === "agenda") {
//this.router.navigate(['/home/', service, IdObject, 'home']);
this.viewEventDetail(data.IdObject)
}
else if (data.Service === "gabinete-digital" && data.Object === "expediente") {
console.log('expediante 1')
this.viewExpedientDetail(data.IdObject)
}
else if (data.Service === "gabinete-digital" && data.Object === "event-list") {
// this.ngZone.run(() => {this.router.navigate(['/home/gabinete-digital/event-list', IdObject])})
this.openApproveModal(data.IdObject);
}
else if (data.Service === "accoes" && data.Object === "accao") {
this.viewPublications(data.IdObject)
alert(data.IdObject)
}
else if (data.Service === "accoes" && data.Object === "publicacao") {
this.viewPublicationDetail(data.IdObject)
}
this.fcm.onNotification().subscribe(data => {
this.viewEventDetail(data.IdObject)
if (data.wasTapped === true) {
console.log("Received in background: ", data);
if (data.Service === "agenda") {
//this.router.navigate(['/home/', service, IdObject, 'home']);
this.viewEventDetail(data.IdObject)
}
else if (data.Service === "gabinete-digital" && data.Object === "expediente") {
console.log('expediante 1')
this.viewExpedientDetail(data.IdObject)
}
else if (data.Service === "gabinete-digital" && data.Object === "event-list") {
// this.ngZone.run(() => {this.router.navigate(['/home/gabinete-digital/event-list', IdObject])})
this.openApproveModal(data.IdObject);
}
else if (data.Service === "accoes" && data.Object === "accao") {
this.viewPublications(data.IdObject)
alert(data.IdObject)
}
else if (data.Service === "accoes" && data.Object === "publicacao") {
this.viewPublicationDetail(data.IdObject)
}
} else {
console.log("Received in foreground: ", data);
console.log(data.Service)
console.log(data.Object)
console.log(data.IdObject)
};
});
}
} else {
console.log("Received in foreground: ", data);
console.log(data.Service)
console.log(data.Object)
console.log(data.IdObject)
};
});
}