mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
PushNotification With Mobilefirst added
This commit is contained in:
+81
-46
@@ -16,6 +16,8 @@ import { ExpedienteDetailPage } from '../pages/gabinete-digital/expediente/exped
|
|||||||
import { ViewPublicationsPage } from '../pages/publications/view-publications/view-publications.page';
|
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 { 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 { 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; */
|
/* const { PushNotifications, LocalNotifications, LocalNotificationAction } = Plugins; */
|
||||||
|
|
||||||
@@ -60,7 +62,7 @@ export class HomePage implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
public modalCtrl: AlertController,
|
public modalCtrl: AlertController,
|
||||||
// private fcm: FCM,
|
private toastService: ToastService,
|
||||||
private animationController: AnimationController,
|
private animationController: AnimationController,
|
||||||
private notificatinsservice: NotificationsService,
|
private notificatinsservice: NotificationsService,
|
||||||
private platform: Platform) {
|
private platform: Platform) {
|
||||||
@@ -107,20 +109,14 @@ export class HomePage implements OnInit {
|
|||||||
wlCommonInit() {
|
wlCommonInit() {
|
||||||
|
|
||||||
this.mobileFirstTest();
|
this.mobileFirstTest();
|
||||||
|
this.mobileFirstPush();
|
||||||
}
|
}
|
||||||
|
|
||||||
mobileFirstTest() {
|
mobileFirstTest() {
|
||||||
this.zone.run(() => {
|
|
||||||
alert("Hello MobileFirst");
|
|
||||||
alert("Connecting to Server...");
|
|
||||||
});
|
|
||||||
WLAuthorizationManager.obtainAccessToken("").then(
|
WLAuthorizationManager.obtainAccessToken("").then(
|
||||||
(token) => {
|
(token) => {
|
||||||
alert('--> pingMFP(): Success '+ token);
|
console.log('MobileFirst Server connect: Success '+ token);
|
||||||
this.zone.run(() => {
|
|
||||||
alert("Yay!");
|
|
||||||
alert("Connected to MobileFirst Server");
|
|
||||||
});
|
|
||||||
var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
|
var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
|
||||||
WLResourceRequest.GET
|
WLResourceRequest.GET
|
||||||
);
|
);
|
||||||
@@ -129,73 +125,112 @@ export class HomePage implements OnInit {
|
|||||||
resourceRequest.send().then(
|
resourceRequest.send().then(
|
||||||
(response) => {
|
(response) => {
|
||||||
// Will display "Hello world" in an alert dialog.
|
// Will display "Hello world" in an alert dialog.
|
||||||
alert("Success: " + response.responseText);
|
console.log("Connect with JavaAdapter Success: " + response.responseText);
|
||||||
//this.MFPushNotification();
|
//this.MFPushNotification();
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
alert("Failure: " + JSON.stringify(error));
|
alert("Connect with JavaAdapter Failure: " + JSON.stringify(error));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
alert('--> pingMFP(): failure '+ error.responseText);
|
console.log('MobileFirst Server connect: failure '+ error.responseText);
|
||||||
alert(JSON.stringify(error))
|
console.log(JSON.stringify(error))
|
||||||
this.zone.run(() => {
|
/* this.zone.run(() => {
|
||||||
alert("Bummer...");
|
alert("Bummer...");
|
||||||
alert("Failed to connect to MobileFirst Server");
|
alert("Failed to connect to MobileFirst Server");
|
||||||
});
|
}); */
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
mobileFirstPush() {
|
mobileFirstPush() {
|
||||||
this.zone.run(() => {
|
|
||||||
alert("Hello Push notification MobileFirst");
|
|
||||||
alert("Connecting to Server...");
|
|
||||||
});
|
|
||||||
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
|
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
|
||||||
(token) => {
|
(token) => {
|
||||||
alert('--> pingMFP(): Success '+ token);
|
console.log('Push Notification: Success '+ token);
|
||||||
this.zone.run(() => {
|
|
||||||
alert("Yay!");
|
|
||||||
alert("Connected to MobileFirst Server");
|
|
||||||
});
|
|
||||||
|
|
||||||
MFPPush.initialize (
|
MFPPush.initialize (
|
||||||
function(successResponse) {
|
function(successResponse) {
|
||||||
alert("Successfully intialized");
|
console.log("Push notification Successfully intialized: " + successResponse);
|
||||||
//MFPPush.registerNotificationsCallback(notificationReceived);
|
MFPPush.registerNotificationsCallback(notificationReceived);
|
||||||
},
|
},
|
||||||
function(failureResponse) {
|
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");
|
MFPPush.registerDevice(null, function(successResponse) {
|
||||||
resourceRequest.send().then(
|
console.log("Successfully registered: "+ successResponse);
|
||||||
(response) => {
|
|
||||||
// Will display "Hello world" in an alert dialog.
|
|
||||||
alert("Success: " + response.responseText);
|
|
||||||
//this.MFPushNotification();
|
|
||||||
},
|
},
|
||||||
(error) => {
|
function(failureResponse) {
|
||||||
alert("Failure: " + JSON.stringify(error));
|
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) => {
|
}, (error) => {
|
||||||
alert('--> pingMFP(): failure '+ error.responseText);
|
console.log('Push notification recived: failure '+ error.responseText);
|
||||||
alert(JSON.stringify(error))
|
console.log(JSON.stringify(error))
|
||||||
this.zone.run(() => {
|
|
||||||
alert("Bummer...");
|
|
||||||
alert("Failed to connect to MobileFirst Server");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
// pushCordova() {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user