Web Screenlet for iOS

Requirements

Compatibility

  • iOS 9 and above

Xamarin Requirements

  • Visual Studio 7.2
  • Mono .NET framework 5.4.1.6

Features

Web Screenlet lets you display any web page. It also lets you customize the web page through injection of local and remote JavaScript and CSS files. If you’re using @product@ as backend, you can use Application Display Templates in your page to customize its content from the server side.

Module

  • None

Themes

  • Default

The Default Theme uses an iOS WKWebView for displaying the web page.

Figure 1: Web Screenlet using the Default Theme.

Figure 1: Web Screenlet using the Default Theme.

Configuration

To learn how to use Web Screenlet, follow the steps in the tutorial Rendering Web Pages in Your iOS App. That tutorial gives detailed instructions for using the configuration items described here.

Web Screenlet has WebScreenletConfiguration and WebScreenletConfigurationBuilder objects that you can use together to supply the parameters that the Screenlet needs to work. WebScreenletConfigurationBuilder has the following methods, which let you supply the described configuration parameters:

MethodReturnsExplanation
addJs(localFile: String)WebScreenletConfigurationBuilderAdds a local JavaScript file with the supplied filename.
addCss(localFile: String)WebScreenletConfigurationBuilderAdds a local CSS file with the supplied filename.
addJs(url: String)WebScreenletConfigurationBuilderAdds a JavaScript file from the supplied URL.
addCss(url: String)WebScreenletConfigurationBuilderAdds a CSS file from the supplied URL.
set(webType: WebType)WebScreenletConfigurationBuilderSets the WebType.
enableCordova()WebScreenletConfigurationBuilderEnables Cordova inside the Web Screenlet.
load()WebScreenletConfigurationReturns the WebScreenletConfiguration object that you can set to the Screenlet instance.

WebType

  • WebType.liferayAuthenticated (default): Displays a @product@ page that requires authentication. The user must therefore be logged in with Screens via Login Screenlet or a SessionContext method. For this WebType, the URL you must pass to the WebScreenletConfigurationBuilder constructor is a relative URL. For example, if the full URL is http://screens.liferay.org.es/web/guest/blog, then the URL you must supply to the constructor is /web/guest/blog.

  • WebType.other: Displays any other page. For this WebType, the URL you must pass to the WebScreenletConfigurationBuilder constructor is a full URL. For example, if the full URL is http://screens.liferay.org.es/web/guest/blog, then you must supply that URL to the constructor.

Attributes

AttributeData typeExplanation
autoLoadbooleanWhether to load the page automatically when the Screenlet appears in the app’s UI. The default value is true.
loggingEnabledbooleanWhether logging is enabled.
isScrollEnabledbooleanWhether to enable scrolling on the page inside the Screenlet.

Delegate

Web Screenlet delegates some events to an object that conforms to the WebScreenletDelegate protocol. This protocol lets you implement the following methods:

  • onWebLoad(_:url:): Called when the Screenlet loads the page.

    func onWebLoad(_ screenlet: WebScreenlet, url: String) {
        ...
    }
    
  • screenlet(_:onScriptMessageNamespace:onScriptMessage:): Called when the WKWebView sends a message.

    func screenlet(_ screenlet: WebScreenlet,
               onScriptMessageNamespace namespace: String,
               onScriptMessage message: String) {
        ...
    }
    
  • screenlet(_:onError:): Called when an error occurs in the process. The NSError object describes the error.

    func screenlet(_ screenlet: WebScreenlet, onError error: NSError) {
        ...
    }
    
« File Display Screenlet for iOSSyncManagerDelegate »
Was this article helpful?
0 out of 0 found this helpful