Advanced Configuration
Portals instances can be further configured by providing a Capacitor Configuration to the Portal.
Capacitor Config File
Providing a Capacitor Configuration json file with your web assets will configure Capacitor with the provided settings.
iOS
Provide a capacitor.config.json
in the Portal start directory (where the web assets are located).
note
Each Portal may have its own config file.
Android
Provide a capacitor.config.json
in the assets
directory of your Android project.
note
This single config will apply to all instances of Portals in your project.
Programmatic Configuration
Portals for Android allows you to provide a programmatically defined Capacitor Configuration to customize the behavior of Capacitor in each instance of a Portal.
Android
- Kotlin
- Java
val fragment = PortalFragment(portal)
/*
* Create your configuration and apply it to
* the Portal fragment before using it
*/
val myConfig = CapConfig.Builder(this)
.setInitialFocus(true)
.setLoggingEnabled(false)
.create()
fragment.setConfig(myConfig)
supportFragmentManager
.beginTransaction()
.replace(R.id.container, fragment)
.commit()
PortalFragment fragment = new PortalFragment(myPortal);
/*
* Create your configuration and apply it to
* the Portal fragment before using it
*/
CapConfig myConfig = new CapConfig.Builder(getContext())
.setInitialFocus(true)
.setLoggingEnabled(false)
.create();
fragment.setConfig(myConfig);
fragmentManager.beginTransaction()
.replace(R.id.portal_space, fragment)
.commit();