Each platform has its own way to display a server-driven screen on frontend by using Beagle. You can see how it’s done in iOS below:
To render a server-driven screen, just create an instance BeagleScreenViewController
and the type is remote
, then you make the initialization with your BFF’s URL, like the example below:
let beagleViewController = Beagle.screen(
.remote(
.init(url: "// URL AQUI")
)
)
After that, now present it where you want. In this case, you must follow the command:
present(beagleViewController, animated: true, completion: nil)
The answer of your BFF must be a JSON that represent a visual component locally defined in the application.
BeagleScreenViewController
initialization URL.Now, run the application and see a defined screen in a remoted rendered URL in your local application.
Congratulations, you now displayed a full server-driven screen. 🎉
Now, it is possible to create screens with dynamic content and you can control in your backend.
To render a screen of a JSON, you just have to create a BeagleScreenViewController
instance of the declarativeText
type and initialize with the JSON, see the example below:
let beagleViewController = Beagle.screen(
.declarativeText(
.init(text: "// JSON HERE")
)
)
After that, now just present it where you want to. On this case, you have to follow the command in the example below:
present(beagleViewController, animated: true, completion: nil)
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.