Using Ionic 2 with IBM MobileFirst 8.0


#1

I am using on Ionic 2 app( v3.10.2 ). I would like to integrate IBM MobileFirst Adapter integration for authentication on my app. I have done with all setup’s. Now i am not able to use worklight.ts class on my angular 4 app.

///
import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;

declare var WLResourceRequest;

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
balance;
resourceRequest;
constructor(public navCtrl: NavController) {

    this.resourceRequest = new WLResourceRequest("/adapters/MyHttpAdapter1/getFeed",WLResourceRequest.GET);

        this.resourceRequest.send().then((response) => {
            this.balance = response.responseText;
            console.log(this.balance);
        },
        function(error){
            console.log(error);
        });
}

}

I Registered this app with my local IBM MobileFirst dev server.

I can communicate those adapters through web app. but not on Ionic / angular 4 app.

Error

Error: Uncaught (in promise): ReferenceError: WLResourceRequest is not defined
ReferenceError: WLResourceRequest is not defined
    at new HomePage (http://localhost:8100/build/main.js:170:36)
    at createClass (http://localhost:8100/build/vendor.js:11251:26)
    at createDirectiveInstance (http://localhost:8100/build/vendor.js:11082:37)
    at createViewNodes (http://localhost:8100/build/vendor.js:12445:49)
    at createRootView (http://localhost:8100/build/vendor.js:12350:5)
    at callWithDebugContext (http://localhost:8100/build/vendor.js:13565:42)
    at Object.debugCreateRootView [as createRootView] (http://localhost:8100/build/vendor.js:13025:12)
    at ComponentFactory_.create (http://localhost:8100/build/vendor.js:10271:46)
    at ComponentFactoryBoundToModule.create (http://localhost:8100/build/vendor.js:3807:29)
    at Tab.NavControllerBase._viewInit (http://localhost:8100/build/vendor.js:43515:44)
    at c (http://localhost:8100/build/polyfills.js:3:13535)
    at Object.reject (http://localhost:8100/build/polyfills.js:3:12891)
    at Tab.NavControllerBase._fireError (http://localhost:8100/build/vendor.js:43273:16)
    at Tab.NavControllerBase._failed (http://localhost:8100/build/vendor.js:43261:14)
    at http://localhost:8100/build/vendor.js:43316:59
    at t.invoke (http://localhost:8100/build/polyfills.js:3:9283)
    at Object.onInvoke (http://localhost:8100/build/vendor.js:4508:37)
    at t.invoke (http://localhost:8100/build/polyfills.js:3:9223)
    at r.run (http://localhost:8100/build/polyfills.js:3:4452)
    at http://localhost:8100/build/polyfills.js:3:14076

Environment info:

MobileFirst Platform 8.0

MobileFirst CLI 8.0.0-2017091111

Ionic Framework: 3.6.1

Ionic App Scripts: 2.1.4

Angular Core: 4.1.3

Angular Compiler CLI: 4.1.3

Node: 6.9.5

Cordova : 7.0.1

OS Platform: Windows 10

Navigator Platform: Win32

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36