Connected to mobilefirst

This commit is contained in:
Eudes Inácio
2021-06-11 17:27:31 +01:00
parent fced696738
commit 3951d306a9
5 changed files with 1643 additions and 475 deletions
+95 -1
View File
@@ -1,4 +1,5 @@
//<reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
///<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 { Event } from '../models/event.model';
@@ -75,6 +76,7 @@ export class HomePage implements OnInit {
}
ngOnInit() {
this.wlCommonInit();
//Add a test
//this.pushCordova();
@@ -102,6 +104,98 @@ export class HomePage implements OnInit {
}
wlCommonInit() {
this.mobileFirstTest();
}
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");
});
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));
}
);
}, (error) => {
alert('--> pingMFP(): failure '+ error.responseText);
alert(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");
});
MFPPush.initialize (
function(successResponse) {
alert("Successfully intialized");
//MFPPush.registerNotificationsCallback(notificationReceived);
},
function(failureResponse) {
alert("Failed to initialize");
}
);
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));
}
);
}, (error) => {
alert('--> pingMFP(): failure '+ error.responseText);
alert(JSON.stringify(error))
this.zone.run(() => {
alert("Bummer...");
alert("Failed to connect to MobileFirst Server");
});
}
);
}
// pushCordova() {