WL Class Reference
Inherits from | NSObject |
Declared in | WL.h |
Overview
The WL singleton class provides a centralized point of control and coordination for IBM MobileFirst Platform hybrid apps. A major role of this class is to handle the initialization of a IBM MobileFirst Platform hybrid application.
Instance Methods
addActionReceiver:
Registers a new native action receiver with the Worklight framework.
- (void)addActionReceiver:(id<WLActionReceiver>)wlActionreceiver
Parameters
- actionReceiver
object that implements the WLActionReceiver protocol
Availability
IBM Worklight V6.2.0
Example:
MyReceiver *myReceiver = [MyReceiver new];
[[WL sharedInstance] addActionReceiver:myReceiver];
Declared In
WL.h
initializeWebFrameworkWithDelegate:
Initialize the IBM MobileFirst Platform web framework
- (void)initializeWebFrameworkWithDelegate:(id)delegate
Discussion
@param delegate
Declared In
WL.h
mainHtmlFilePath
This method returns the path to the application main HTML file.
- (NSString *)mainHtmlFilePath
Return Value
the URL of the main HTML file
Discussion
Warning: This API should be used after the successful callback of wlInitWebFrameworkDidCompleteWithResult. This is to ensure that the IBM MobileFirst Platform framework initialization is complete and the web resources are ready to be used.
Declared In
WL.h
removeActionReceiver:
Unregisters a receiver from receiving actions. After calling this API, the receiver will no longer receive actions.
- (void)removeActionReceiver:(id<WLActionReceiver>)wlActionreceiver
Parameters
- actionReceiver
object that implements the WLActionReceiver protocol
Example:
MyReceiver *myReceiver = [MyReceiver new]; [[WL sharedInstance] removeActionReceiver:myReceiver];
Declared In
WL.h
sendActionToJS:
Sends action to JavaScript action receivers.
- (void)sendActionToJS:(NSString *)action
Parameters
- action
custom string representing an action
Discussion
Note: if there are no JavaScript action receivers registered, the action is queued until a JavaScript action receiver is registered.
Declared In
WL.h
sendActionToJS:withData:
Sends action and optional data object to JavaScript action receivers.
- (void)sendActionToJS:(NSString *)action withData:(NSDictionary *)data
Parameters
- action
custom string representing an action
- data
(optional) custom NSDictionary instance containing key-value pairs
Discussion
Note: if there are no JavaScript action receivers registered, the action is queued until a JavaScript action receiver is registered.
Example:
[[WL sharedInstance] sendActionToJS:@"doSomething"];
NSMutableDictionary *data = [NSDictionary dictionaryWithObject:@"12345" forKey:@"customData"];
[[WL sharedInstance] sendActionToJS:@"doSomething" data:data];
Declared In
WL.h
serverUrl
Returns the current IBM MobileFirst Platform server URL
- (NSURL *)serverUrl
Return Value
IBM MobileFirst Platform server URL
Declared In
WL.h
setServerUrl:
Sets the IBM MobileFirst Platform server URL to the specified URL.
- (void)setServerUrl:(NSURL *)url
Parameters
- url
- The URL of the new server, including protocol, IP, port, and context.
Discussion
Changes the IBM MobileFirst Platform server URL to the new URL and cleans the HTTP client context. After calling this method, the application is not logged in to any server.
Notes:
- The responsibility for checking the validity of the URL is on the developer.
- For hybrid applications: This call does not clean the HTTP client context saved in JavaScript.
For hybrid applications, it is recommended to set the server URL by using the following JavaScript function:
WL.App.setServerUrl
.
Example:
[[WL sharedInstance] setServerUrl:[NSURL URLWithString:@"http://9.148.23.88:10080/context"]];</code>
Declared In
WL.h
showSplashScreen
This method will show a splash screen on-top of the current window.
- (void)showSplashScreen
Discussion
IBM MobileFirst Platform default application will show a splash screen during application start-up, and will hide it using the JavaScript API WL.App.hideSplashScreen(), once the main html page is loaded. This is done to improve the user experience and allow smooth transition from the native application container to the WebView, hiding the underlying page loading activity. This method will use the launch images supplied in the application XCode project. This method is not related to the splash screen feature which is available through the Cordova framework.
Warning: A root view controller must be defined before calling this method.
Declared In
WL.h