PredixAppWindowProtocol

@objc public protocol PredixAppWindowProtocol : class

Primary interface for the PredixMobileSDK to communicate with the UI.

Used to display the main UI, and the Authentication UI

Informs the UI when to display a native UI waiting component (spinner or progress bar)

Provides communication channel for notifications (script execution)

  • LoadURL will be called when the SDK wants the UI to display a new page, i.e. a Predix Mobile WebApp.

    Prior to calling LoadURL any attachments associated with the webapp document will be extracted.

    The example Predix Mobile iOS container uses this to indicate how scrolling behavior should be handled within the web view.

    Declaration

    Swift

    func loadURL(_ url: URL, parameters: [AnyHashable: Any]?, onComplete : (() -> Void)?)

    Parameters

    url

    URL to the HTML page the UI should load. Generally this is the file indicated in the main property of the webapp document, but may also be other values such as about:blank, non-URLs in the case of non-hybrid native applications, or for the authentication UI, URLs associated with offline password management.

    parameters

    The properties from the webapp document. Generally these are included in the webapp.json file when doing a pm publish. The webapp document can thus be used to pass infromation to the container for how to behave when loading the webapp.

    onComplete

    Optional closure, that if included should be called when the URL load has been completed.

  • Informs the UI that the wait state should be updated, optionally displaying a message.

    Wait state visualizations can be progress bars, spinners, text, etc.

    Declaration

    Swift

    func updateWaitState(_ state: WaitState, message: String?)
  • Returns the current wait state to the SDK on request.

    The SDK will call this when a GET request has been made to the window service, spinner path (http:/pmapi/window/spinner)

    Declaration

    Swift

    func waitState() -> (WaitStateReturn)
  • Called when the SDK wants to send a message to the UI; generally a JavaScript command to be run in a webapp.

    This method is not usually implemented for native UI implementations.

    Notifications coming from the SDK will be sent to the WebApp through this method.

    For webapps, the provided script should be executed via a command like: stringByEvaluatingJavaScript(from: String)

    Declaration

    Swift

    @objc optional func receiveAppNotification(_ script: String)

    Parameters

    script

    The script string to evaluate.