Skip navigation links

Index Overview

PREV CLASS NEXT CLASS FRAMES (opens in new window)



Class WL.App

WL.App


Method Summary
Method Attributes Method Name and Description
 

__copyToClipboard(string, callback)

This method is applicable to iOS and Android.

 

addActionReceiver(callback)

Registers an action receiver.

 

getDeviceLanguage()

Returns the language code.

 

getDeviceLocale()

Returns the locale code.

 

getErrorMessage(exception)

Extracts a string that contains an error message.

 

getServerUrl(successCallback, failCallback)

Gets MobileFirst server URL.

 

hideSplashScreen()

Hides the default IBM MobileFirst splash screen if it is shown, and does nothing if the default MobileFirst splash screen is already hidden

 

openURL(url, target, options)

Open a URL.

 

removeActionReceiver()

Removes a previously added receiver.

 

sendActionToNative(action, data)

Sends an action and optional data object to native action receivers.

 

setServerUrl(url, successCallback, failCallback)

This method is applicable to iOS, Android and WP8.

 

showSplashScreen()

Shows the default IBM MobileFirst splash screen on the activity that was passed as a parameter

Method Detail

__copyToClipboard

__copyToClipboard(string, callback)

This method is applicable to iOS and Android. It copies the specified string to the clipboard.

Parameters:
{String} string - Mandatory. The text to be copied to the clipboard.
callback - Optional. For Android environments only. The callback function that is called after the data is copied to the clipboard.

addActionReceiver

addActionReceiver(callback)

Registers an action receiver.

Parameters:
{String} id. - A string parameter used to uniquely identify receiver function, to be able to remove it at later stages.
{Function} callback - Mandatory. The JavaScript function that is called by the MobileFirst framework when an action is sent from native code to JavaScript code.
Example:

WL.App.addActionReceiver("MyReceiver", function (receivedActon){ // process receivedAction });

Note:
In JavaScript code, a receiver must be implemented as a callback that can receive an object.

getDeviceLanguage

getDeviceLanguage()

Returns the language code. Returns the language code according to user device settings, for example: en.


getDeviceLocale

getDeviceLocale()

Returns the locale code. Returns the locale code according to user device settings, for example: en_US.


getErrorMessage

getErrorMessage(exception)

Extracts a string that contains an error message.

Extracts a string that contains the error message within the specified exception object. Use for exceptions that are thrown by the IBM® MobileFirst® client runtime framework.

Parameters:
{exception} exception - Mandatory. The exception object from which the error string is extracted.

getServerUrl

getServerUrl(successCallback, failCallback)

Gets MobileFirst server URL. This method is asynchronous, so the MobileFirst server URL is returned as an argument to the successCallback function.

Parameters:
successCallback - Mandatory. The callback function that is called with the MobileFirst server URL as an argument.
failCallback - Optional. The callback function that is called if this method fails.

hideSplashScreen

hideSplashScreen()

Hides the default IBM MobileFirst splash screen if it is shown, and does nothing if the default MobileFirst splash screen is already hidden

Deprecated:
Since version 8.0

openURL

openURL(url, target, options)

Open a URL. The behavior depends on the application platform.

Opens the specified URL according to the specified target and options (specs). The behavior of this method depends on the application environment, as follows:

Environment Description
Android Replaces the application with a new default browser window at the specified URL. The target and options parameters are ignored. The application is not closed; pressing Back on the phone brings the user back to the application.
iPhone, iPad Replaces the application with a new Safari window at the specified URL. The target and options parameters are ignored.
Mobile web apps Opens a new browser window at the specified URL. Whether the target and options parameters are ignored or not depends on the specific mobile browser.
Windows Phone 8 Replaces the application with a new Internet Explorer window at the specified URL. The target and options parameters are ignored.
Windows 8 Replaces the application with a new Internet Explorer window at the specified URL. The target and options parameters are ignored.
Other environments If the value of the target parameter is _self or unspecified, replaces the application iframe with the specified URL. Otherwise, opens a new browser window with the specified URL. The target and options parameters are NOT ignored.
Parameters:
url - Mandatory. The URL of the web page to be opened.
target - Optional. The value to be used as the target (or name) parameter of the JavaScript window.open method. If no value is specified, _self is used.
options - Optional. The value to be used as the options (or specs) parameter of the JavaScript window.open method.
If no value is specified, the following options are used:
status=1, toolbar=1, location=1, menubar=1, directories=1, resizable=1, scrollbars=1
Returns:
A reference to the newly opened window, or NULL if no window was opened.

removeActionReceiver

removeActionReceiver()

Removes a previously added receiver. After this API is called, the receiver identified by receiverId no longer receives actions.

Parameters:
{String} id. - A string parameter used to uniquely identify a previously registered receiver function.
Example:

WL.App.removeActionReceiver("MyReceiver");


sendActionToNative

sendActionToNative(action, data)

Sends an action and optional data object to native action receivers.

Parameters:
{String} action - Custom string that represents an action. All receivers registered with the specified action receive the message.
data - Optional parameter: custom JSON object containing key-value pairs.
Example:

WL.App.sendActionToNative("doSomething"); WL.App.sendActionToNative("doSomething", { customData: 12345} );

Note:
If there are no native action receivers registered, the action is queued until a native action receiver is registered.

setServerUrl

setServerUrl(url, successCallback, failCallback)

This method is applicable to iOS, Android and WP8. Sets the MobileFirst server URL to the specified URL.

Changes the MobileFirst server URL to the new URL, cleans the HTTP client context, and calls successCallback when finished. After calling this method, the application is not logged in to any server. If the specified URL is malformed, then failCallback is called and the MobileFirst server URL remains unchanged.

Notes:

Parameters:
{String} url - Mandatory. The URL of the new server, including protocol, IP, port, and context.
successCallback - Optional. The callback function that is called after the MobileFirst URL is set to the specified URL.
failCallback - Optional. The callback function that is called if this method fails or is not supported.
Example:

WL.App.setServerUrl("http://9.148.23.88:10080/context", successCallback, failCallback);


showSplashScreen

showSplashScreen()

Shows the default IBM MobileFirst splash screen on the activity that was passed as a parameter

Deprecated:
Since version 8.0

© Copyright IBM Corp. 2011, 2016.