PortalBuilder

class PortalBuilder(val name: String)

A class used to create Portal instances. It follows a Builder Pattern and can be used in situations where you want to programmatically create a Portal at runtime instead of using one directly in an XML layout.

Example usage (kotlin):

val portal: Portal = PortalBuilder("myPortal")
.addPlugin(MyCapacitorPlugin::class.java)
.setPortalFragmentType(MyFadeInOutPortalFragment::class.java)
.setInitialContext(mapOf("myVariableFromAndroid" to 42))
.setStartDir("web_app")
.create()

Example usage (java):

Portal portal = new PortalBuilder("myPortal")
.addPlugin(MyCapacitorPlugin.class)
.setPortalFragmentType(MyFadeInOutPortalFragment.class)
.setInitialContext(Map.of("myVariableFromAndroid", 42))
.setStartDir("web_app")
.create();

Constructors

Link copied to clipboard

Functions

Link copied to clipboard

Add an Asset Map to the Portal used with shared assets.

Link copied to clipboard
fun addPlugin(plugin: Class<out Plugin?>): PortalBuilder

Add a plugin to be loaded with the Portal.

Link copied to clipboard
fun addPluginInstance(plugin: Plugin): PortalBuilder

Add a plugin instance to be loaded with the Portal.

Link copied to clipboard
fun create(): Portal

Creates the Portal instance from the current state of the PortalBuilder provided. This finishes building the Portal.

Link copied to clipboard

Set a list of AssetMap to the Portal used with shared assets.

Link copied to clipboard

Set development mode on the Portal which will look for a server URL set by the Portals CLI. This is set to true by default but can be turned off manually if desired.

Link copied to clipboard
fun setInitialContext(initialContext: Any): PortalBuilder

Sets the initial context to pass to the web view. You can pass in either a Map or a String that will be parsed into a JSON object.

Link copied to clipboard
fun setLiveUpdateConfig(context: Context, liveUpdateConfig: LiveUpdate, updateOnAppLoad: Boolean = true): PortalBuilder

Set the LiveUpdate config if using the Live Updates SDK with Portals.

Link copied to clipboard
fun setPlugins(plugins: MutableList<Class<out Plugin?>>): PortalBuilder

Set a list of Capacitor Plugin to be loaded with the Portal.

Link copied to clipboard

Set the PortalFragment class used with displaying the Portal when added to an XML layout.

Link copied to clipboard

Set the directory of the Portal. This directory is the on device directory of where your web application is located.

Properties

Link copied to clipboard

the name of the Portal