The IBM Worklight client-side API

In this chapter, you will learn how the IBM Worklight client-side API can improve mobile application development. You will also see the IBM Worklight server-side API improve client/server integration and communication between mobile applications and back end systems.

The IBM Worklight client-side API allows mobile applications to access most of the features that are available in IBM Worklight during runtime, in order to get access to some defined libraries that appear to be bundled into the mobile application. Integration of the libraries for your mobile application using Worklight Server is used to access predefined communication interfaces. These libraries also offer unified access to native device features, which streamlines application development.

The IBM Worklight client-side API contains hybrid, native, mixed hybrid, and web-based APIs. Besides, it extends those of these APIs that are responsible for supporting every mobile development framework. The development framework for a mobile application is used to improve security including custom and built-in authentication mechanisms for IBM Worklight provided by client-side API modules. It provides a semantic connection between web technologies such as HTML5, CSS3, and JavaScript with native functions that are available for different mobile platforms.

The WLClient JavaScript client library

This collection of topics lists the public methods of the IBM Worklight runtime client API for mobile apps, desktop, and the Web.

WLClient is a JavaScript client library that provides access to IBM Worklight capabilities. This library initializes the re-rendering of applications. It manages the authenticated sessions, all general information handling, data corporate information systems for the purpose of manipulation, storing and retrieving user preferences throughout the sessions, internationalized application texts, and environment-specific UI behavior. It stores the custom log lines, which deal with special tables that exist in the database, in order to prepare audits and reports. It is used to write debug lines on the logger window and device-specific functions for iPhone, Android, Windows Mobile, and BlackBerry.

It contains asynchronous JavaScript calls, which takes an options parameter. In reply to the JavaScript call, success and failure handlers receive a response parameter. The API consists of many non-linear calls, which we will be demonstrating here.

The function onSuccess is used to initialize the application. If an onFailure function is not passed, a default onFailure function is called. If onFailure is passed, it overrides any specific failure-handling function. The WL.Client library contains the following methods:

  • WL.Client.init: This method sets the WL.Client object. The options for methods are present in the initOptions.js file. The syntax for WL.Client.init is WL.Client.init({options}).
  • WL.Client.invokeProcedure: This is a method that invokes a procedure that is exposed by an IBM Worklight Adapter. The syntax for WL.Client.invokeProcedure is WL.Client invokeProcedure (invocationData, options).
  • WL.Client.isConnected: This is a method that has been deprecated since IBM Worklight v4.1.3. Use the WL.Device.getNetworkInfo method instead. It returns true if the application is connected to IBM Worklight Server. The syntax for WL.Client.isConnected is: WL.Client.isConnected().
  • WL.Client.isUserAuthenticated: This is a method that checks whether the user is authenticated in a specified resource realm or in the resource realm that was assigned to the application when it was deployed. This method returns true if the user is authenticated in the realm and false otherwise. The syntax for WL.Client.isUserAuthenticated is WL.Client.isUserAuthenticated(realm).
  • WL.Client.login: This method is used to log in to a specific realm and it is an asynchronous function. The syntax for WL.Client.login is WL.Client.login(realm, options).
  • WL.Client.logout: This method logs out to a specific realm and it is an asynchronous function. The syntax for WL.Client.logout is WL.Client.logout(realm, options).

Besides these, there are some other WL.Client implementations that are stated according to the behavior of a particular application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.181.146