For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


MobileFirst Cordova plug-in initialization for analytics

The MobileFirst Cordova plug-in prepares your app for sending analytics data to the server. If your app does not use analytics, this code can be removed.

After startup create two listeners for receiving device events. In the WebView JavaScript code, the data can then be sent with WL.Analytics.send().

WLAnalytics.init(this); WLAnalytics.addDeviceEventListener(WLAnalytics.DeviceEvent.NETWORK); WLAnalytics.addDeviceEventListener(WLAnalytics.DeviceEvent.LIFECYCLE);

The MobileFirst Cordova plug-in inserts this listener code into the onCreate method of MFPApplication. If not needed it can be removed.

The WL.Analytics.send() must be added as needed in the index.js file, or any subsequently added JavasScript files.

For more information on MobileFirst see Analytics and Logger.

Parent topic: Developing Cordova apps for Android