Especific route on click for pushNotification

This commit is contained in:
Eudes Inácio
2021-02-01 09:58:15 +01:00
parent 81b374f8f6
commit 95d2736370
3 changed files with 46 additions and 11 deletions
+32 -10
View File
@@ -8,11 +8,11 @@ import { ModalController } from '@ionic/angular';
import { PublicationDetailPage } from '../../app/pages/publications/view-publications/publication-detail/publication-detail.page';
import { ViewPublicationsPage } from '../../app/pages/publications/view-publications/view-publications.page';
import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed } from '@capacitor/core';
import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, Modals } from '@capacitor/core';
import { Router } from '@angular/router';
import { MethodCall } from '@angular/compiler';
const { PushNotifications } = Plugins;
const { PushNotifications, LocalNotifications } = Plugins;
@Component({
selector: 'app-home',
@@ -72,7 +72,9 @@ export class HomePage implements OnInit {
PushNotifications.addListener(
'pushNotificationReceived',
(notification: PushNotification) => {
alert('Push received: ' + JSON.stringify(notification));
//alert('Push received: ' + JSON.stringify(notification));
//this.localNotificationPresent(notification);
},
);
@@ -87,7 +89,7 @@ export class HomePage implements OnInit {
let publicationId = notification.notification.data.publicationId;
let processId = notification.notification.data.processId;
console.log('FOLDER PROCESS',folder.ProcessId)
console.log('FOLDER PROCESS', folder.ProcessId)
if (service != null) {
@@ -98,20 +100,20 @@ export class HomePage implements OnInit {
} else if (service === "gabinete-digital") {
this.router.navigate(['/home/', service]);
} else if (service === "gabinete-digital-expediente") {
this.router.navigate(['/home/gabinete-digital/', object,idObject]);
}
this.router.navigate(['/home/gabinete-digital/', object, idObject]);
}
} else {
if ( processId || publicationId != null) {
this.viewPublicationDetail(processId,publicationId)
if (processId || publicationId != null) {
this.viewPublicationDetail(processId, publicationId)
}
if (notification.notification.data.folder.ProcessId != null) {
this.viewPublications(folder)
}
}
/*switch (service) {
@@ -147,6 +149,26 @@ export class HomePage implements OnInit {
);
}
async localNotificationPresent(notification) {
LocalNotifications.schedule({
notifications: [
{
title: notification.title,
body: notification.body,
id: 1,
schedule: { at: new Date(Date.now() + 1000) },
sound: null,
attachments: null,
actionTypeId: "",
extra: null
}
]
});
}
async viewPublicationDetail(processId: string, publicationId: string) {
const modal = await this.modalController.create({
component: PublicationDetailPage,
+8 -1
View File
@@ -82,7 +82,13 @@ export class LoginPage implements OnInit {
this.storageService.store(this.username, token.value);
this.storageService.get(this.username).then(value => {
console.log('STORAGE TOKEN',value )
})
this.storageService.get(AuthConnstants.USER).then(res=>{
console.log('USERID',res);
});
});
},
);
@@ -103,6 +109,7 @@ export class LoginPage implements OnInit {
if (await this.authService.login(this.userattempt)) {
/* this.loginRocketChat(); */
this.storeUserIdANdToken()
this.router.navigate(['/home/events']);
}
else {