Git pull made

This commit is contained in:
Eudes Inácio
2021-11-05 10:19:41 +01:00
33 changed files with 461 additions and 2032 deletions
+31 -86
View File
@@ -1,6 +1,5 @@
/* eslint-disable */
/* tslint:disable */
/* ///<reference path="../../../plugins/cordova-plugin-mfp-push/typings/mfppush.d.ts" /> */
import { Injectable, NgZone } from '@angular/core';
import { ActivatedRoute } from '@angular/router'
import { HttpClient } from '@angular/common/http';
@@ -48,10 +47,11 @@ export class NotificationsService {
private activeroute: ActivatedRoute,
private jsonstore: JsonStore,
private eventtrigger: EventTrigger,
private backgroundservice: BackgroundService,
private fcm: FCM) {
private backgroundservice: BackgroundService) {
this.storageService.get("Notifications").then((value) => {
this.storageService.get("Notifications").then((value) => {
}).catch(()=>{
}).catch(() => {
@@ -88,63 +88,6 @@ export class NotificationsService {
return this.http.get<Token[]>(`${geturl}`);
}
getAndpostToken(username) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
} else {
const geturl = environment.apiURL + 'notifications/token';
return this.fcm.getToken().then(token => {
console.log('token: ', token)
this.storageService.store(username, token);
this.storageService.get(username).then(value => {
console.log('STORAGE TOKEN', value)
this.storageService.get(AuthConnstants.USER).then(res => {
console.log('USERID', res);
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
const body = {
UserId: res.UserId,
TokenId: token,
Status: 1,
Service: 1
};
this.http.post<Token>(`${geturl}`, body, { headers }).subscribe(data => {
console.log('TOKEN USER MIDLE', data);
})
});
});
});
}
}
async onReceviNotification() {
this.fcm.onNotification().subscribe(data => {
if (data.click_action) {
console.log("Received in background: ", data);
this.notificatinsRoutes(data)
} else {
console.log("Received in foreground: ", data);
console.log(data.Service)
console.log(data.Object)
console.log(data.IdObject)
/* this.DataArray.push(data)
console.log("On ReceiveNotification", this.DataArray)
this.storageService.store("Notifications", this.DataArray) */
};
});
}
/////////////////////////////////////////////////////
/* getTokenByUserIdAndId(user, userID) {
@@ -226,7 +169,6 @@ export class NotificationsService {
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
(token) => {
console.log('Push Notification: Success ' + token);
window['MFPPush'].initialize(
function (successResponse) {
console.log("Push notification Successfully intialized: " + successResponse);
@@ -236,30 +178,33 @@ export class NotificationsService {
console.log("Push notification failure intialized: " + failureResponse);
}
);
var notificationReceived = (message) => {
//this.jsonstore.createCollection('Notifications',message);
this.DataArray.push(message)
console.log("On ReceiveNotification", this.DataArray)
this.storageService.store("Notifications",this.DataArray)
console.log(message);
this.eventtrigger.publishSomeData({
notification: "recive"
})
var data = JSON.parse(message.payload);
//synchro.$send(data)
console.log('data.Service', data.Service); // module
console.log('data.IdObject', data.IdObject); // Object id
console.log('data.Object', data.Object); // details
if(message.actionName){
this.notificatinsRoutes(data);
} else {
/* this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
//this.notificatinsRoutes(data);
console.log(data)
window['MFPPush'].registerDevice(null, async (successResponse) => {
console.log("Successfully registered: " + JSON.stringify(successResponse));
console.log('token: ', successResponse.deviceId)
await this.storageService.store(username, successResponse.deviceId).then((tokennoti) => {
console.log('token store',tokennoti)
});
await this.storageService.get(username).then(value => {
console.log('STORAGE TOKEN', value)
this.storageService.get(AuthConnstants.USER).then(res => {
console.log('USERID', res);
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
const body = {
UserId: res.UserId,
TokenId: successResponse.deviceId,
Status: 1,
Service: 1
};
this.http.post<Token>(`${geturl}`, body, { headers }).subscribe(data => {
console.log('TOKEN USER MIDLE', data);
})
});
});
},
function (failureResponse) {
console.log("Successfully failue: " + JSON.stringify(failureResponse));
}
this.callbacks.forEach( e=> {