Closed emmanuelOpenForge closed 3 months ago
I'm sorry, but I don't quite understand what is happening here. It's adding ionic for a loading and about screen replacement? I'm not really sure this is a direction we want to move towards honestly.
was there ever any intention of integrating with Ionic? 🤔
this is not something we want to implement. when submitting pull requests, please work from issues marked 'Help Wanted'!
Steps to Create a New Ionic Portal
Initialize an Angular Project
To begin, we will initialize an Angular project at the root of your project directory using Angular CLI.
Note: Ensure you have Angular CLI installed with the command:
Now, create an Angular application with the command:
Install Ionic Portals
Once the project is created, proceed to install Ionic Portals in the Angular project to facilitate communication between the web app and the native application. Use the command:
Additionally, add Ionic to design your loading page:
Modify the Main View
In the main view of the web app (
app.component.html
), add elements to show the information about Open Forge:Add Event for the Button
In
app.component.ts
, add an event for the button to return to the previous scene from the About view:We have imported the
publish
method from Ionic Portals, which will be used to communicate with the native application through PubSub communication. Here, our web app will be the publisher, notifying that we want to navigate back by communicating via the channel/topicnavigate
with databack
, indicating we want to go back to the previous scene. Our native application will be the subscriber, and upon receiving this message, it will terminate the Ionic Portal and navigate to the previous scene in the menu list.Build the Application
Finally, build the application with the command:
Then, copy the generated code from the
dist
folder to the main folder of your native app (in this case,HabiticaRPG
), and rename the folder toHabiticaAboutOFPortal
as this name will be used to initialize our Ionic portal later.Create a New Scene in iOS
The first step to create our Ionic portal from the native application side is to create a new UIView scene which will use the
AboutOFViewController
controller with the following code:In the code above,
HabiticaAboutOFPortal
is the name of the folder containing your web app generated withnpm run build
.This allows us to initialize our Ionic portal by overriding the
loadView()
method:Subscribe to the Event
The code that listens for the event from our web app in the
viewDidLoad
lifecycle hook is:Where
dismissCancellable
is of typeAnyCancellable?
. This code subscribes to thenavigate
topic (the channel), receives data as aString
on the main thread, and navigates to the previous scene in our storyboard.Modify Main Menu for Navigation
Also, define in
MainMenuViewController
to enable navigation in the menu by adding the following code at line 109:In our
Strings.swift
file, add the label for the menu button:Finally, in the
StoryboardScene
file:This guide demonstrates how to use micro frontends in your native application and communicate between the web app and the native app. I hope this information was useful and enjoyable. Please share this publication, as we frequently share similar material to keep everyone updated. Thank you for your attention, and see you in the next guide.