Cache of Firebase token

This commit is contained in:
Eudes Inácio
2021-01-22 16:03:05 +01:00
parent f1f7e18b5f
commit bb30a98de1
33 changed files with 568 additions and 642 deletions
@@ -271,6 +271,8 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _angular_common__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @angular/common */ "./node_modules/@angular/common/__ivy_ngcc__/fesm2015/common.js");
/* harmony import */ var _services_processes_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../services/processes.service */ "./src/app/services/processes.service.ts");
/* harmony import */ var _capacitor_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @capacitor/core */ "./node_modules/@capacitor/core/dist/esm/index.js");
/* harmony import */ var _angular_router__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @angular/router */ "./node_modules/@angular/router/__ivy_ngcc__/fesm2015/router.js");
@@ -279,9 +281,10 @@ __webpack_require__.r(__webpack_exports__);
const { PushNotifications } = _capacitor_core__WEBPACK_IMPORTED_MODULE_5__["Plugins"];
let HomePage = class HomePage {
constructor(eventService, processesbackend) {
constructor(eventService, processesbackend, router) {
this.eventService = eventService;
this.processesbackend = processesbackend;
this.router = router;
this.totalEvent = 0;
this.totalExpediente = 0;
}
@@ -303,13 +306,21 @@ let HomePage = class HomePage {
this.processesbackend.GetTasksList("Expediente", true).subscribe(result => {
this.totalExpediente = result;
});
PushNotifications.requestPermission().then(result => {
PushNotifications.register();
});
PushNotifications.addListener('registration', (token) => {
alert('Push registration success, token: ' + token.value);
console.log('FIREBASE: ', token.value);
});
/*
(PushNotifications as any).requestPermission().then(result => {
PushNotifications.register();
});
PushNotifications.addListener(
'registration',
(token: PushNotificationToken) => {
alert('Push registration success, token: ' + token.value);
console.log('FIREBASE: ', token.value)
this.storageService.store(this.username,token.value);
},
);
console.log(this.storageService.get(this.username)) */
PushNotifications.addListener('registrationError', (error) => {
alert('Error on registration: ' + JSON.stringify(error));
});
@@ -317,13 +328,15 @@ let HomePage = class HomePage {
alert('Push received: ' + JSON.stringify(notification));
});
PushNotifications.addListener('pushNotificationActionPerformed', (notification) => {
alert('Push action performed: ' + JSON.stringify(notification));
alert('Push action performed: ' + JSON.stringify(notification.notification.data));
this.router.navigate(['/home/events']);
});
}
};
HomePage.ctorParameters = () => [
{ type: _services_events_service__WEBPACK_IMPORTED_MODULE_2__["EventsService"] },
{ type: _services_processes_service__WEBPACK_IMPORTED_MODULE_4__["ProcessesService"] }
{ type: _services_processes_service__WEBPACK_IMPORTED_MODULE_4__["ProcessesService"] },
{ type: _angular_router__WEBPACK_IMPORTED_MODULE_6__["Router"] }
];
HomePage = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Component"])({
File diff suppressed because one or more lines are too long
@@ -483,15 +483,22 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var _capacitor_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
/*! @capacitor/core */
"./node_modules/@capacitor/core/dist/esm/index.js");
/* harmony import */
var _angular_router__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
/*! @angular/router */
"./node_modules/@angular/router/__ivy_ngcc__/fesm2015/router.js");
var PushNotifications = _capacitor_core__WEBPACK_IMPORTED_MODULE_5__["Plugins"].PushNotifications;
var HomePage = /*#__PURE__*/function () {
function HomePage(eventService, processesbackend) {
function HomePage(eventService, processesbackend, router) {
_classCallCheck(this, HomePage);
this.eventService = eventService;
this.processesbackend = processesbackend;
this.router = router;
this.totalEvent = 0;
this.totalExpediente = 0;
}
@@ -519,13 +526,22 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
this.processesbackend.GetTasksList("Expediente", true).subscribe(function (result) {
_this.totalExpediente = result;
});
PushNotifications.requestPermission().then(function (result) {
PushNotifications.register();
});
PushNotifications.addListener('registration', function (token) {
alert('Push registration success, token: ' + token.value);
console.log('FIREBASE: ', token.value);
});
/*
(PushNotifications as any).requestPermission().then(result => {
PushNotifications.register();
});
PushNotifications.addListener(
'registration',
(token: PushNotificationToken) => {
alert('Push registration success, token: ' + token.value);
console.log('FIREBASE: ', token.value)
this.storageService.store(this.username,token.value);
},
);
console.log(this.storageService.get(this.username)) */
PushNotifications.addListener('registrationError', function (error) {
alert('Error on registration: ' + JSON.stringify(error));
});
@@ -533,7 +549,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
alert('Push received: ' + JSON.stringify(notification));
});
PushNotifications.addListener('pushNotificationActionPerformed', function (notification) {
alert('Push action performed: ' + JSON.stringify(notification));
alert('Push action performed: ' + JSON.stringify(notification.notification.data));
_this.router.navigate(['/home/events']);
});
}
}]);
@@ -546,6 +564,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
type: _services_events_service__WEBPACK_IMPORTED_MODULE_2__["EventsService"]
}, {
type: _services_processes_service__WEBPACK_IMPORTED_MODULE_4__["ProcessesService"]
}, {
type: _angular_router__WEBPACK_IMPORTED_MODULE_6__["Router"]
}];
};
File diff suppressed because one or more lines are too long
@@ -125,6 +125,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _ionic_angular__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @ionic/angular */ "./node_modules/@ionic/angular/__ivy_ngcc__/fesm2015/ionic-angular.js");
/* harmony import */ var src_app_services_storage_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! src/app/services/storage.service */ "./src/app/services/storage.service.ts");
/* harmony import */ var src_app_services_photo_service__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! src/app/services/photo.service */ "./src/app/services/photo.service.ts");
/* harmony import */ var _capacitor_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @capacitor/core */ "./node_modules/@capacitor/core/dist/esm/index.js");
@@ -134,6 +135,8 @@ __webpack_require__.r(__webpack_exports__);
const { PushNotifications } = _capacitor_core__WEBPACK_IMPORTED_MODULE_9__["Plugins"];
let LoginPage = class LoginPage {
constructor(router, authService, storageService, toastService, photoService, alertController) {
this.router = router;
@@ -173,6 +176,19 @@ let LoginPage = class LoginPage {
console.log('Network error');
});
} */
storeUserIdANdToken() {
PushNotifications.requestPermission().then(result => {
PushNotifications.register();
});
PushNotifications.addListener('registration', (token) => {
console.log('FIREBASE TOKEN', token.value);
this.storageService.store(this.username, token.value);
this.storageService.get(this.username).then(value => {
console.log('STORAGE TOKEN', value);
});
});
}
;
Login() {
return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, function* () {
/* try { */
@@ -187,6 +203,7 @@ let LoginPage = class LoginPage {
};
if (yield this.authService.login(this.userattempt)) {
/* this.loginRocketChat(); */
this.storeUserIdANdToken();
this.router.navigate(['/home/events']);
}
else {
File diff suppressed because one or more lines are too long
@@ -252,6 +252,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var src_app_services_photo_service__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
/*! src/app/services/photo.service */
"./src/app/services/photo.service.ts");
/* harmony import */
var _capacitor_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(
/*! @capacitor/core */
"./node_modules/@capacitor/core/dist/esm/index.js");
var PushNotifications = _capacitor_core__WEBPACK_IMPORTED_MODULE_9__["Plugins"].PushNotifications;
var LoginPage = /*#__PURE__*/function () {
function LoginPage(router, authService, storageService, toastService, photoService, alertController) {
@@ -323,6 +331,24 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
});
} */
}, {
key: "storeUserIdANdToken",
value: function storeUserIdANdToken() {
var _this = this;
PushNotifications.requestPermission().then(function (result) {
PushNotifications.register();
});
PushNotifications.addListener('registration', function (token) {
console.log('FIREBASE TOKEN', token.value);
_this.storageService.store(_this.username, token.value);
_this.storageService.get(_this.username).then(function (value) {
console.log('STORAGE TOKEN', value);
});
});
}
}, {
key: "Login",
value: function Login() {
@@ -332,7 +358,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
switch (_context2.prev = _context2.next) {
case 0:
if (!this.validateInput()) {
_context2.next = 11;
_context2.next = 12;
break;
}
@@ -347,28 +373,29 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
case 4:
if (!_context2.sent) {
_context2.next = 8;
_context2.next = 9;
break;
}
/* this.loginRocketChat(); */
this.storeUserIdANdToken();
this.router.navigate(['/home/events']);
_context2.next = 9;
_context2.next = 10;
break;
case 8:
case 9:
//this.toastService.presentToast('Não foi possível fazer login"');
this.presentAlert('O nome de utilizador e palavra-passe estão incorretas ou verifique a sua conexão com a internet e volte a tentar.');
case 9:
_context2.next = 12;
case 10:
_context2.next = 13;
break;
case 11:
case 12:
//this.toastService.presentToast('Preencha todos campos');
this.presentAlert('Por favor, insira o seu nome de utilizador e palavra-passe.');
case 12:
case 13:
case "end":
return _context2.stop();
}
File diff suppressed because one or more lines are too long