Skip to content

Instantly share code, notes, and snippets.

@jthoms1
Last active September 28, 2021 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jthoms1/07d948e28dbdfba5bda76ad6472e36bc to your computer and use it in GitHub Desktop.
Save jthoms1/07d948e28dbdfba5bda76ad6472e36bc to your computer and use it in GitHub Desktop.
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);
}, []);
// ...
}
};
import io.ionic.portals.Portal;
import io.ionic.portals.PortalFragment;
class ProfileFragment : PortalFragment {
override fun onViewCreated(@NotNull View view, Bundle savedInstanceState) {
val portal: Portal = PortalBuilder("myPortal")
.addPlugin(ShopAPIPlugin::class.java)
.setInitialContext(mapOf("startingRoute" to "/home"))
.setStartDir("web_app")
.create()
var portalView = PortalWebView();
super.onViewCreated(portalView, savedInstanceState);
}
}
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: portal)
super.viewDidLoad()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment