mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
PushNotification With Mobilefirst added
This commit is contained in:
+83
-48
@@ -16,6 +16,8 @@ import { ExpedienteDetailPage } from '../pages/gabinete-digital/expediente/exped
|
||||
import { ViewPublicationsPage } from '../pages/publications/view-publications/view-publications.page';
|
||||
import { ApproveEventModalPage } from '../pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page';
|
||||
import { PublicationDetailPage } from '../pages/publications/view-publications/publication-detail/publication-detail.page';
|
||||
import { ToastService } from '../services/toast.service';
|
||||
import { SuccessMessagePage } from '../shared/popover/success-message/success-message.page';
|
||||
|
||||
/* const { PushNotifications, LocalNotifications, LocalNotificationAction } = Plugins; */
|
||||
|
||||
@@ -60,7 +62,7 @@ export class HomePage implements OnInit {
|
||||
private router: Router,
|
||||
private modalController: ModalController,
|
||||
public modalCtrl: AlertController,
|
||||
// private fcm: FCM,
|
||||
private toastService: ToastService,
|
||||
private animationController: AnimationController,
|
||||
private notificatinsservice: NotificationsService,
|
||||
private platform: Platform) {
|
||||
@@ -107,20 +109,14 @@ export class HomePage implements OnInit {
|
||||
wlCommonInit() {
|
||||
|
||||
this.mobileFirstTest();
|
||||
this.mobileFirstPush();
|
||||
}
|
||||
|
||||
mobileFirstTest() {
|
||||
this.zone.run(() => {
|
||||
alert("Hello MobileFirst");
|
||||
alert("Connecting to Server...");
|
||||
});
|
||||
WLAuthorizationManager.obtainAccessToken("").then(
|
||||
(token) => {
|
||||
alert('--> pingMFP(): Success '+ token);
|
||||
this.zone.run(() => {
|
||||
alert("Yay!");
|
||||
alert("Connected to MobileFirst Server");
|
||||
});
|
||||
console.log('MobileFirst Server connect: Success '+ token);
|
||||
|
||||
var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
|
||||
WLResourceRequest.GET
|
||||
);
|
||||
@@ -129,73 +125,112 @@ export class HomePage implements OnInit {
|
||||
resourceRequest.send().then(
|
||||
(response) => {
|
||||
// Will display "Hello world" in an alert dialog.
|
||||
alert("Success: " + response.responseText);
|
||||
console.log("Connect with JavaAdapter Success: " + response.responseText);
|
||||
//this.MFPushNotification();
|
||||
},
|
||||
(error) => {
|
||||
alert("Failure: " + JSON.stringify(error));
|
||||
alert("Connect with JavaAdapter Failure: " + JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
}, (error) => {
|
||||
alert('--> pingMFP(): failure '+ error.responseText);
|
||||
alert(JSON.stringify(error))
|
||||
this.zone.run(() => {
|
||||
console.log('MobileFirst Server connect: failure '+ error.responseText);
|
||||
console.log(JSON.stringify(error))
|
||||
/* this.zone.run(() => {
|
||||
alert("Bummer...");
|
||||
alert("Failed to connect to MobileFirst Server");
|
||||
});
|
||||
}); */
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
mobileFirstPush() {
|
||||
this.zone.run(() => {
|
||||
alert("Hello Push notification MobileFirst");
|
||||
alert("Connecting to Server...");
|
||||
});
|
||||
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
alert('--> pingMFP(): Success '+ token);
|
||||
this.zone.run(() => {
|
||||
alert("Yay!");
|
||||
alert("Connected to MobileFirst Server");
|
||||
});
|
||||
console.log('Push Notification: Success '+ token);
|
||||
|
||||
MFPPush.initialize (
|
||||
function(successResponse) {
|
||||
alert("Successfully intialized");
|
||||
//MFPPush.registerNotificationsCallback(notificationReceived);
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
MFPPush.registerNotificationsCallback(notificationReceived);
|
||||
},
|
||||
function(failureResponse) {
|
||||
alert("Failed to initialize");
|
||||
console.log("Push notification failure intialized: " + failureResponse);
|
||||
}
|
||||
);
|
||||
var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
|
||||
WLResourceRequest.GET
|
||||
);
|
||||
|
||||
resourceRequest.setQueryParameter("name", "world");
|
||||
resourceRequest.send().then(
|
||||
(response) => {
|
||||
// Will display "Hello world" in an alert dialog.
|
||||
alert("Success: " + response.responseText);
|
||||
//this.MFPushNotification();
|
||||
},
|
||||
(error) => {
|
||||
alert("Failure: " + JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
MFPPush.registerDevice(null, function(successResponse) {
|
||||
console.log("Successfully registered: "+ successResponse);
|
||||
},
|
||||
function(failureResponse) {
|
||||
console.log("Successfully failue: "+ failureResponse);
|
||||
}
|
||||
);
|
||||
async function notificationReceived(message) {
|
||||
alert(message.alert);
|
||||
console.log(message)
|
||||
|
||||
var jsonObject = JSON.parse(message.payload);
|
||||
console.log(jsonObject.service);
|
||||
console.log(jsonObject.IdObject);
|
||||
console.log(jsonObject.object);
|
||||
|
||||
}
|
||||
}, (error) => {
|
||||
alert('--> pingMFP(): failure '+ error.responseText);
|
||||
alert(JSON.stringify(error))
|
||||
this.zone.run(() => {
|
||||
alert("Bummer...");
|
||||
alert("Failed to connect to MobileFirst Server");
|
||||
});
|
||||
console.log('Push notification recived: failure '+ error.responseText);
|
||||
console.log(JSON.stringify(error))
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
async successMessage(message?: any, callback?) {
|
||||
|
||||
const enterAnimation = (baseEl: any) => {
|
||||
const backdropAnimation = this.animationController.create()
|
||||
.addElement(baseEl.querySelector('ion-backdrop')!)
|
||||
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
||||
|
||||
const wrapperAnimation = this.animationController.create()
|
||||
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
||||
.keyframes([
|
||||
{ offset: 0, opacity: '1', right: '-100%' },
|
||||
{ offset: 1, opacity: '1', right: '0px' }
|
||||
]);
|
||||
|
||||
return this.animationController.create()
|
||||
.addElement(baseEl)
|
||||
.easing('ease-out')
|
||||
.duration(500)
|
||||
.addAnimation([backdropAnimation, wrapperAnimation]);
|
||||
}
|
||||
|
||||
const leaveAnimation = (baseEl: any) => {
|
||||
return enterAnimation(baseEl).direction('reverse');
|
||||
}
|
||||
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
enterAnimation,
|
||||
leaveAnimation,
|
||||
component: SuccessMessagePage,
|
||||
componentProps: {
|
||||
message: message || 'Processo efetuado' ,
|
||||
},
|
||||
cssClass: 'notification-modal'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
if (callback) {
|
||||
callback()
|
||||
}
|
||||
modal.dismiss()
|
||||
},7000)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// pushCordova() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user