mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
Connected to mobilefirst
This commit is contained in:
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user