A powerful API for enhanced native experiences
Portals provides a powerful cross-platform API to expose native functionality for embedding rich web apps in a controlled manner, a robust web-to-native communication bridge—and coming soon, cloud services for real-time app updates and more. Interested in testing it out early? Make sure to drop us a note.
import IonicPortals
class HomeViewController: AppParticipantViewController {
override func ViewDidLoad() { let portal = PortalBuilder("myPortal") .setInitialContext(["startingRoute", "/home"]) .setStartDir("web_app") .create() self.view = PortalWebView(frame: view.frame, portal: por super.viewDidLoad() }
}
import io.ionic.portals.Portal;import io.ionic.portals.PortalFragment;
class ProfileFragment : PortalFragment { override fun onViewCreated(@NotNull View view, Bubdle savedInstanceState ) { val portal: Portal = PortalBuilder("myPortal") .addPlugin(ShopAPIPlugin::class.java) .asetInitialContext(mapOf("startingRoute” to "/home”) .setStartDir("web_app") .create()
var portalView = PortalWebView();
super.onViewCreated(portalView, savedInstanceState); }}
import ShopAPI from './ShopAPIPlugin';import Portals from '@ionic/portals';
const App: React.FC<InitialContext> = () => { const [sessionInfo, setSession] = useState(null); const [startingRoute, setInitialRoute] = useState(null);
useEffect(() => { const { context, sessionInfo } = await Promise.all( Portals.getInitialContext()); ShopAPI.getSessionInfo()); ); setInitialRoute(context.startingRoute); setSessionInfo(sessionInfo); }, []);
// ...