Last active
September 28, 2021 16:43
-
-
Save jthoms1/07d948e28dbdfba5bda76ad6472e36bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}, []); | |
// ... | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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