WLClientSwift

public class WLClientSwift : NSObject, IBMMobileFirstPlatformFoundation.WLDelegate, WLDelegateSwift

This singleton class exposes methods that you use to communicate with the IBM MobileFirst Platform Server.

  • This method returns the shared instance of WLClientSwift.

    Declaration

    Swift

    public static func sharedInstance() -> WLClientSwift

    Return Value

    WLCLientSwift shared instance

  • Retrieves the shared cookie storage that is used by the framework when communicating with the server.

    Declaration

    Swift

    public func HTTPCookieStorage() -> HTTPCookieStorage

    Return Value

    The cookie storage object

  • This method uses URLConnection to execute the provided URLRequest.

    Declaration

    Swift

    public func send(request: URLRequest, delegate: Any)

    Parameters

    request

    URLRequest object.

    delegate

    An object that conforms to the NSURLSessionDataDelegate or NSURLSessionTaskDelegate protocol.

  • This method uses URLConnection to execute the provided URLRequest.

    Declaration

    Swift

    public func send(request: URLRequest, responseQueue: DispatchQueue, delegate: Any)

    Parameters

    request

    URLRequest object.

    responseQueue

    A callback queue of type DispatchQueue

    delegate

    An object that conforms to the NSURLSessionDataDelegate or NSURLSessionTaskDelegate protocol.

  • You can use this method to register a challenge handler, which is a class that inherits either from GatewayChallengeHandlerSwift or SecurityCheckChallengeHandlerSwift.

    Declaration

    Swift

    public func registerChallengeHandler(challengeHandler: BaseChallengeHandler)

    Parameters

    challengeHandler

    The challenge handler to register.

  • You use this method to add a global header, which is sent on each request. Each WlRequest instance will use this header as an HTTP header.

    Declaration

    Swift

    public func addGlobalHeader(headerName: String, headerValue: String)

    Parameters

    headerName

    The header name/key.

    value

    The header value.

  • You use this method to remove a global header, which is no longer sent with each request.

    Declaration

    Swift

    public func removeGlobalHeader(headerName: String)

    Parameters

    headerName

    The header name/key to be removed.

  • Get global headers.

    Declaration

    Swift

    public func getGlobalHeaders() -> [AnyHashable : Any]

    Return Value

    Global headers

  • Get challenge handler by realm key.

    Declaration

    Swift

    public func getChallengeHandler(bySecurityCheck: String) -> BaseChallengeHandler

    Return Value

    Challenge handler object.

  • This method sets the interval, in seconds, at which the client (device) sends a heartbeat signal to the server.

    You use the heartbeat signal to prevent a session with the server from timing out because of inactivity. Typically, the heartbeat interval has a value that is less than the server session timeout.The server session timeout is defined in the worklight.properties file. By default, the value of the heartbeat interval is set to 420 seconds (7 minutes). To disable the heartbeat signal, set a value that is less than, or equal to zero.

    Note

    The client sends a heartbeat signal to the server only when the application is in the foreground. When the application is sent to the background, the client stops sending heartbeat signals. The client resumes sending heartbeat signals when the application is brought to the foreground again.

    Declaration

    Swift

    public func setHeartBeatInterval(interval: Int)

    Parameters

    interval

    The interval, in seconds, at which the heartbeat signal is sent to the server.

  • Sets the IBM MobileFirst Platform server URL to the specified URL.

    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.

    Note

    The responsibility for checking the validity of the URL is on the developer.

    Declaration

    Swift

    public func setServerUrl(url: URL)

    Parameters

    url

    The URL of the new server, including protocol, IP, port, and context.

  • Returns the current IBM MobileFirst Platform server URL.

    Declaration

    Swift

    public func serverUrl() -> URL

    Return Value

    IBM MobileFirst Platform server URL

  • 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.

    Declaration

    Swift

    public func pinTrustedCertificatePublicKey(certificateFilename: String)

    Parameters

    certificateFilename

    The name of the certificate file.

  • Pins a list of host X509 certificates with public key to the client application. Secured calls to the all pinned remote host will be checked for a public key match. Secured calls to other hosts containing other certificates not pinned with app 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.

    Declaration

    Swift

    public func pinTrustedCertificatePublicKey(certificateFilenames: Array<Any>)

    Parameters

    certificateFilenames

    The list conatining names of the certificate files.

  • Sets the display name of the device. The display name is stored in the MobileFirst Server registration data.

    Declaration

    Swift

    public func setDeviceDisplayName(displayName:String , onCompletion : @escaping(Error?) -> Void)

    Parameters

    displayName

    The device display name to set.

    onCompletion

    A closure call-back.

  • Gets the display name of the device. The display name is retrieved from the MobileFirst Server registration data.

    Declaration

    Swift

    public func getDeviceDisplayName(onCompletion: @escaping(String? ,Error?) -> Void)

    Parameters

    onCompletion

    A closure call-back.