Requirements
- Xcode 9.3 or above
- iOS 11 SDK
- Liferay Portal 6.2 CE/EE, Liferay CE Portal 7.0/7.1, Liferay DXP 7.0+
- Liferay Screens Compatibility app (CE or EE/DXP). This app is preinstalled in Liferay CE Portal 7.0/7.1 and Liferay DXP 7.0+.
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 Liferay DXP 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.
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:
Method | Returns | Explanation |
---|---|---|
addJs(localFile: String) | WebScreenletConfigurationBuilder | Adds a local JavaScript file with the supplied filename. |
addCss(localFile: String) | WebScreenletConfigurationBuilder | Adds a local CSS file with the supplied filename. |
addJs(url: String) | WebScreenletConfigurationBuilder | Adds a JavaScript file from the supplied URL. |
addCss(url: String) | WebScreenletConfigurationBuilder | Adds a CSS file from the supplied URL. |
set(webType: WebType) | WebScreenletConfigurationBuilder | Sets the WebType . |
enableCordova() | WebScreenletConfigurationBuilder | Enables Cordova inside the Web Screenlet. |
load() | WebScreenletConfiguration | Returns the WebScreenletConfiguration object that you can set to the Screenlet instance. |
WebType
-
WebType.liferayAuthenticated (default): Displays a Liferay DXP page that requires authentication. The user must therefore be logged in with Screens via Login Screenlet or a
SessionContext
method. For thisWebType
, the URL you must pass to theWebScreenletConfigurationBuilder
constructor is a relative URL. For example, if the full URL ishttp://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 theWebScreenletConfigurationBuilder
constructor is a full URL. For example, if the full URL ishttp://screens.liferay.org.es/web/guest/blog
, then you must supply that URL to the constructor.
Attributes
Attribute | Data type | Explanation |
---|---|---|
autoLoad | boolean | Whether to load the page automatically when the Screenlet appears in the app’s UI. The default value is true . |
loggingEnabled | boolean | Whether logging is enabled. |
isScrollEnabled | boolean | Whether 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 theWKWebView
sends a message.func screenlet(_ screenlet: WebScreenlet, onScriptMessageNamespace namespace: String, onScriptMessage message: String) { ... }
-
screenlet(_:onError:)
: Called when an error occurs in the process. TheNSError
object describes the error.func screenlet(_ screenlet: WebScreenlet, onError error: NSError) { ... }