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
+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']);
}