diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index ff4dd179a..c9c6a9591 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -67,6 +67,7 @@ export class HomePage implements OnInit { ngOnInit() { if(!this.platform.is('desktop')) { + this.mobilefirstConnect(); this.notificatinsservice.onReceviNotification(); } this.count(); @@ -99,4 +100,35 @@ export class HomePage implements OnInit { } + mobilefirstConnect() { + WLAuthorizationManager.obtainAccessToken("").then( + (token) => { + console.log('MobileFirst Server connect: Success ' + token); + + 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. + console.log("Connect with JavaAdapter Success: " + response.responseText); + //this.MFPushNotification(); + }, + (error) => { + alert("Connect with JavaAdapter Failure: " + JSON.stringify(error)); + } + ); + }, (error) => { + 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"); + }); */ + } + ); + } + } diff --git a/src/index.html b/src/index.html index f596b10a7..c85c54d3d 100644 --- a/src/index.html +++ b/src/index.html @@ -7,7 +7,7 @@ - +