Pushnotification added

This commit is contained in:
Eudes Inácio
2021-04-05 14:17:11 +01:00
parent 50b3a203ca
commit 685321a5db
1524 changed files with 261 additions and 510587 deletions
+44 -3
View File
@@ -1,3 +1,5 @@
///<reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
///<reference path="../../../plugins/cordova-plugin-mfp-push/typings/mfppush.d.ts" />
import { Component, OnInit, NgZone } from '@angular/core';
import { EventsService } from '../services/events.service';
import { formatDate } from '@angular/common';
@@ -34,6 +36,7 @@ export class HomePage implements OnInit {
constructor(private zone: NgZone,private eventService: EventsService, private processesbackend: ProcessesService, private router: Router, private modalController: ModalController,) { }
ngOnInit() {
this.mobileFirstTest()
/* //Initialize profile as mdgpr
let date = new Date();
@@ -111,7 +114,7 @@ export class HomePage implements OnInit {
); */
}
/* mobileFirstTest() {
mobileFirstTest() {
this.zone.run(() => {
alert("Hello MobileFirst");
alert("Connecting to Server...");
@@ -132,20 +135,58 @@ export class HomePage implements OnInit {
(response) => {
// Will display "Hello world" in an alert dialog.
alert("Success: " + response.responseText);
this.MFPushNotification()
},
(error) => {
alert("Failure: " + JSON.stringify(error));
}
);
}, (error) => {
console.log('--> pingMFP(): failure ', error.responseText);
alert(JSON.stringify(error))
this.zone.run(() => {
alert("Bummer...");
alert("Failed to connect to MobileFirst Server");
});
}
);
} */
}
MFPushNotification() {
var pushNotificationReceived = function (message) {
alert(JSON.stringify(message));
}
MFPPush.initialize (
function(successResponse) {
//alert("Successfully intialized");
MFPPush.registerNotificationsCallback(notificationReceived);
},
function(failureResponse) {
console.log("Failed to initialize");
}
);
MFPPush.isPushSupported (
function(successResponse) {
//alert("Push Supported: " + successResponse);
},
function(failureResponse) {
console.log("Failed to get push support status");
}
);
MFPPush.registerDevice(
null,function(successResponse) {
alert("Successfully registered: "+ successResponse);
},
function(failureResponse) {
alert("Successfully registered: "+ failureResponse);
}
);
function notificationReceived(message) {
alert(JSON.stringify(message.alert));
}
}
async openApproveModal(eventSerialNumber){
const modal = await this.modalController.create({