Notification on perfil menu

This commit is contained in:
Eudes Inácio
2021-07-31 22:04:09 +01:00
parent 3b594f2000
commit 7ac8ba793f
6 changed files with 141 additions and 56 deletions
+61 -3
View File
@@ -21,6 +21,7 @@ export class NotificationsService {
adding: "intervenient" | "CC" = "intervenient";
folderId: string;
DataArray: Array<String> = [];
constructor(
private http: HttpClient,
@@ -97,6 +98,62 @@ export class NotificationsService {
}
getAndpostToken2() {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
} else {
const geturl = environment.apiURL + 'notifications/token';
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
(token) => {
console.log('Push Notification: Success ' + token);
window['MFPPush'].initialize(
function (successResponse) {
console.log("Push notification Successfully Service intialized: " + successResponse);
},
function (failureResponse) {
console.log("Push notification failure Service intialized: " + failureResponse);
}
);
window['MFPPush'].registerDevice(null, (successResponse) => {
console.log("Successfully registered: " + JSON.stringify(successResponse));
console.log('token: ', successResponse.deviceId)
/* this.storageService.store(username, successResponse.deviceId);
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': 'Basic cGF1bG8ucGludG9AZ2FiaW5ldGVkaWdpdGFsLmxvY2FsOnRhYnRlc3RlQDAwNg==' };
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));
}
);
}, (error) => {
console.log('Push notification recived: failure ' + error.responseText);
console.log(JSON.stringify(error));
}
);
}
}
async onReceviNotification() {
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
(token) => {
@@ -112,9 +169,10 @@ export class NotificationsService {
}
);
var notificationReceived = (message) => {
this.jsonstore.createCollection('Notifications',message);
this.jsonstore.getCollection('Notifications')
console.log("Notification Store: ", this.jsonstore.getCollection('Notifications'));
//this.jsonstore.createCollection('Notifications',message);
this.DataArray.push(message)
this.storageService.store("Notifications",JSON.stringify(this.DataArray))
console.log(message);
var data = JSON.parse(message.payload);
console.log(data.Service);