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
+11 -3
View File
@@ -4,7 +4,7 @@ import { EventsService } from '../services/events.service';
import { Event } from '../models/event.model'; import { Event } from '../models/event.model';
import { ProcessesService } from '../services/processes.service'; import { ProcessesService } from '../services/processes.service';
import { NotificationsService } from '../services/notifications.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 { AlertController } from 'ionic-angular';
/* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core'; */ /* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core'; */
import { Router } from '@angular/router'; import { Router } from '@angular/router';
@@ -61,7 +61,8 @@ export class HomePage implements OnInit {
public modalCtrl: AlertController, public modalCtrl: AlertController,
private fcm: FCM, private fcm: FCM,
private animationController: AnimationController, private animationController: AnimationController,
private notificatinsservice: NotificationsService,) { private notificatinsservice: NotificationsService,
private platform: Platform) {
router.events.subscribe((val) => { router.events.subscribe((val) => {
document.querySelectorAll('ion-modal').forEach((e) => e.remove()) document.querySelectorAll('ion-modal').forEach((e) => e.remove())
@@ -105,9 +106,13 @@ export class HomePage implements OnInit {
} }
pushCordova() { pushCordova() {
if(this.platform.is('desktop')) {
console.log('Notifications not supported')
} else {
this.fcm.onNotification().subscribe(data => { this.fcm.onNotification().subscribe(data => {
this.viewEventDetail(data.IdObject) this.viewEventDetail(data.IdObject)
if (data.wasTapped) { if (data.wasTapped === true) {
console.log("Received in background: ", data); console.log("Received in background: ", data);
if (data.Service === "agenda") { if (data.Service === "agenda") {
@@ -139,6 +144,9 @@ export class HomePage implements OnInit {
}; };
}); });
}
} }
+16 -2
View File
@@ -10,7 +10,7 @@ import { ExpedientePage } from '../pages/gabinete-digital/expediente/expediente.
import { EventListPage } from '../pages/gabinete-digital/event-list/event-list.page'; import { EventListPage } from '../pages/gabinete-digital/event-list/event-list.page';
import { PublicationsPage } from '../pages/publications/publications.page' import { PublicationsPage } from '../pages/publications/publications.page'
import { ViewPublicationsPage } from '../pages/publications/view-publications/view-publications.page' */ import { ViewPublicationsPage } from '../pages/publications/view-publications/view-publications.page' */
import { ModalController, AlertController, AnimationController } from '@ionic/angular'; import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
import { ViewEventPage } from '../pages/agenda/view-event/view-event.page'; import { ViewEventPage } from '../pages/agenda/view-event/view-event.page';
import { ExpedienteDetailPage } from '../pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page'; import { ExpedienteDetailPage } from '../pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page';
import { PublicationDetailPage } from '../pages/publications/publication-detail/publication-detail.page'; import { PublicationDetailPage } from '../pages/publications/publication-detail/publication-detail.page';
@@ -31,7 +31,8 @@ export class NotificationsService {
private storageService: StorageService, private storageService: StorageService,
private modalController: ModalController, private modalController: ModalController,
public modalCtrl: AlertController, public modalCtrl: AlertController,
private animationController: AnimationController,/* , private animationController: AnimationController,
private platform: Platform/* ,
public agenda: AgendaPage, public agenda: AgendaPage,
public expediante: ExpedientePage, public expediante: ExpedientePage,
public eventList: EventListPage, public eventList: EventListPage,
@@ -45,6 +46,10 @@ export class NotificationsService {
} }
getAndpostToken(username) { 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 => { return this.fcm.getToken().then(token => {
@@ -71,6 +76,8 @@ export class NotificationsService {
}); });
} }
}
async onReceviNotification(viewEventDetail, viewExpedientDetail, openApproveModal, viewPublications, viewPublicationDetail) { async onReceviNotification(viewEventDetail, viewExpedientDetail, openApproveModal, viewPublications, viewPublicationDetail) {
this.fcm.onNotification().subscribe(data => { this.fcm.onNotification().subscribe(data => {
if (data.click_action) { if (data.click_action) {
@@ -105,6 +112,13 @@ export class NotificationsService {
}); });
} }
platformVerify() {
if (this.platform.is('cordova')) {
} else {
}
}
async viewEventDetail(eventId: any) { async viewEventDetail(eventId: any) {
const modal = await this.modalController.create({ const modal = await this.modalController.create({