Notification click open app

This commit is contained in:
Eudes Inácio
2021-04-09 09:48:14 +01:00
parent 54db829b80
commit 0c91f108e2
2 changed files with 33 additions and 56 deletions
+21 -36
View File
@@ -98,48 +98,36 @@ export class HomePage implements OnInit {
pushCordova() {
this.fcm.onNotification().subscribe(data => {
this.viewEventDetail(data.idObject)
this.viewEventDetail(data.IdObject)
if (data.click_action) {
console.log("Received in background: ", data);
if (data.service === "agenda") {
//this.router.navigate(['/home/', service, idObject, 'home']);
this.viewEventDetail(data.idObject)
if (data.Service === "agenda") {
//this.router.navigate(['/home/', service, IdObject, 'home']);
this.viewEventDetail(data.IdObject)
}
else if (data.service === "gabinete-digital" && data.object === "expediente") {
this.viewExpedientDetail(data.idObject)
else if (data.Service === "gabinete-digital" && data.Object === "expediente") {
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 === "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 === "accao") {
this.viewPublications(data.IdObject)
alert(data.IdObject)
}
else if (data.service === "accoes" && data.object === "publicacao") {
this.viewPublicationDetail(data.idObject)
else if (data.Service === "accoes" && data.Object === "publicacao") {
this.viewPublicationDetail(data.IdObject)
}
} else {
console.log("Received in foreground: ", 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") {
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)
}
else if (data.service === "accoes" && data.object === "publicacao") {
this.viewPublicationDetail(data.idObject)
}
console.log(data.Service)
console.log(data.Object)
console.log(data.IdObject)
};
});
@@ -148,12 +136,9 @@ export class HomePage implements OnInit {
// backend.registerToken(token);
});
this.ubscribeToTopic()
this.getToken()
}
ubscribeToTopic() {
/* ubscribeToTopic() {
this.fcm.subscribeToTopic('enappd');
}
getToken() {
@@ -162,7 +147,7 @@ export class HomePage implements OnInit {
// Register your new token in your back-end if you want
// backend.registerToken(token);
});
}
} */
async viewEventDetail(eventId: any) {
console.log(this.profile);
+12 -20
View File
@@ -11,6 +11,7 @@ import { PhotoService } from 'src/app/services/photo.service';
import { NotificationsService } from 'src/app/services/notifications.service';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Token } from '../../models/token.model';
import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
/* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed } from '@capacitor/core';
@@ -38,7 +39,8 @@ export class LoginPage implements OnInit {
private storageService: StorageService,
private toastService: ToastService,
private photoService: PhotoService,
public alertController: AlertController) { }
public alertController: AlertController,
private fcm: FCM) { }
ngOnInit() {
@@ -78,25 +80,18 @@ export class LoginPage implements OnInit {
});
}
/* storeUserIdANdToken() {
(PushNotifications as any).requestPermission().then(result => {
PushNotifications.register();
});
PushNotifications.addListener(
'registration',
(token: PushNotificationToken) => {
console.log('FIREBASE TOKEN', token.value)
this.storageService.store(this.username, token.value);
getToken() {
this.fcm.getToken().then(token => {
console.log('token: ', token)
this.storageService.store(this.username, token);
this.storageService.get(this.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,
TokenId: token.value,
UserId: res.UserId,
TokenId: token,
Status: 1,
Service: 1
};
@@ -107,11 +102,8 @@ export class LoginPage implements OnInit {
});
});
},
);
}; */
});
}
async Login() {
@@ -127,7 +119,7 @@ export class LoginPage implements OnInit {
}
if (await this.authService.login(this.userattempt)) {
this.loginRocketChat();
//this.storeUserIdANdToken();
this.getToken();
this.router.navigate(['/home/events']);
}