Reference Source
import WLClient from 'react-native-ibm-mobilefirst'
public class | source

WLClient

This collection of topics lists the public methods of the IBM® MobileFirst® runtime client API for mobile apps, desktop, and web. WL.Client is a JavaScript client library that provides access to IBM MobileFirst capabilities. You can use WL.Client to perform the following types of functions:

Method Summary

Public Methods
public

addGlobalHeader(name: string, value: string)

Adds a HTTP header to all requests made by the MobileFirst SDK.

public

Gets the display name of the device.

public

Returns the current MobileFirst Platform server URL.

public

pinTrustedCertificatesPublicKey(certificateFileNames: string[])

Pins the host X509 certificate public key to the client application.

public

registerChallengeHandler(challengeHandlerClass: ChallengeHandler, securityCheckName: string)

Register a challenge handler to handle act upon challenges provided for a given security check.

public

async setDeviceDisplayName(deviceDisplayName: string): *

Sets the friendly name of the device.

public

setHeartbeatInterval(heartbeatIntervalInSeconds: number)

The number of seconds between which a heartbeat request is sent to the MobileFirst server to keep the connection alive.

public

setServerUrl(serverUrl: string)

public

submitChallengeAnswer(securityCheckName: string, answer: object)

Send an answer back to the security check that triggered this challenge.

Public Methods

public addGlobalHeader(name: string, value: string) source

Adds a HTTP header to all requests made by the MobileFirst SDK. Use the WLClient.removeGlobalHeader API to stop adding the header to further requests

Params:

NameTypeAttributeDescription
name string

Name of the HTTP header

value string

The value of the HTTP header

public async getDeviceDisplayName(): Promise<string> source

Gets the display name of the device. The display name is retrieved from the MobileFirst Server registration data. You can see the device display name in the Devices section of the MobileFirst Console.

Return:

Promise<string>

The display name of the device. For example, "Sam's iPhone"

public async getServerUrl(): Promise<string> source

Returns the current MobileFirst Platform server URL. You can define the server URL in the mfpclient.properties (Android) / mfpclient.plist (iOS) or by calling the WLClient.setServerUrl API

Return:

Promise<string>

The URL of the current MobileFirst Platform server.

public pinTrustedCertificatesPublicKey(certificateFileNames: string[]) source

Pins the host X509 certificate public key to the client application. Secured calls to the pinned remote host will be checked for a public key match. Secured calls to other hosts containing other certificates will be rejected. Some mobile operating systems might cache the certificate validation check results. Your app must call the certificate pinning method before making a secured request. Calling this method a second time overrides any previous pinning operation. The certificates must be in DER format. When multiple certificates are pinned, a secured call is checked for a match with any one of the certificates.

Params:

NameTypeAttributeDescription
certificateFileNames string[]

The list of paths to the certificate files. On Android this will be under the assets folder.

public registerChallengeHandler(challengeHandlerClass: ChallengeHandler, securityCheckName: string) source

Register a challenge handler to handle act upon challenges provided for a given security check.

Params:

NameTypeAttributeDescription
challengeHandlerClass ChallengeHandler

The challenge handler object implementing the methods of a SecurityCheck Challenge handler

securityCheckName string

The name of the security check for which this challenge handler must respond.

Example:

class UserLoginCH { 

   constructor() {} 
   
   handleChallenge(params){
     // Gather credentials from the user
     WLClient.submitChallengeAnswer (securityCheck, credentials); 
   }

   handleSuccess(){
     // Handle success. Perhaps show a success message or do nothing. 
   }

   handleFailure(){
      // Handle failure. Perhaps, show a failure message or ask for credentials again.
   }
}

var userLoginCH = new UserLoginCH(); 
WLClient.registerChallengeHandler(userLoginCH ,"UserLogin") ; 

public async setDeviceDisplayName(deviceDisplayName: string): * source

Sets the friendly name of the device. You can see the device display name in the Devices section of the MobileFirst console.

Params:

NameTypeAttributeDescription
deviceDisplayName string

The friendly name to be set for the device.

Return:

*

public setHeartbeatInterval(heartbeatIntervalInSeconds: number) source

The number of seconds between which a heartbeat request is sent to the MobileFirst server to keep the connection alive. The default interval is 7 minutes or 420 seconds. Heartbeats are sent only when the app is in the foreground.

Params:

NameTypeAttributeDescription
heartbeatIntervalInSeconds number

Heartbeat interval value in seconds

public setServerUrl(serverUrl: string) source

Params:

NameTypeAttributeDescription
serverUrl string

The URL of the MobileFirst Platform server to point to.

Example:

var newserverurl = 'https://mobilefoundation-newserver.mybluemix.net:443/mfp' ;
WLClient.setServerUrl(newserverurl);

public submitChallengeAnswer(securityCheckName: string, answer: object) source

Send an answer back to the security check that triggered this challenge. The answer should be in a JSON format.

Params:

NameTypeAttributeDescription
securityCheckName string

The security check name that represents the challenge. Used to identify which security check requires authentication.

answer object

The challenge answer to be returned to the server. For example, this could be credentials collected from the user.