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: UIViewController { override func loadView() { let portal = Portal( name: "myPortal", startDir: "web_app", initialContext: ["startingRoute": "/home"] ) self.view = PortalUIView(portal: portal) }}
class ProfileFragment : PortalFragment { constructor() : super() constructor(portal: Portal?) : super(portal) companion object { @JvmStatic fun newInstance(): ProfileFragment { val portal: Portal = PortalBuilder("myPortal") .addPlugin(ShopAPIPlugin::class.java) .setInitialContext(mapOf("startingRoute" to "home")) .setStartDir("web_app") .create() return ProfileFragment(portal) } }}
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); }, []);
// ...