You can use the platform's dynamic configuration for application settings that are loaded at runtime. You can also subscribe to changes in these settings. These may include styling options, metadata or feature toggling. Within Studio, these settings are found in the Project > Setup > Experience tab and are specified in your App Spec.
In order to use this capability, you will need to load the Project and obtain data from its fields as follows:
func loadProject() {
// Interact will already be initialised at this stage
Interact.defaultCore.getProject(completion: { [weak self] result in
guard let self = self else { return }
do {
self.display(project: try result.get())
} catch {
// Treat the error
}
})
}
func display(project: Project) {
// You can use project fields in your UI by fetching them like so:
let id = project.id
let myField = project.fields["my_field"]
}
fun loadProject() {
Core.default!!.interact.getProject {
it.onSuccess {
display(project = it)
}
it.onFailure {
// Treat the error, `it` is a throwable
}
}
}
fun display(project: Project) {
// You can use project fields in your UI by fetching them like so:
val id = project.id
val myField = project.fields["my_field"]
}
You can be notified of any update on the project by using this snippet:
// Called whe the project fields are updated
const unsubscribeOnProjectFieldsUpdated = onProjectFieldsUpdated(
project,
() => { console.log(project) }
);
// Called when the project listings are updated
const unsubscribeOnProjectListingsUpdated = onProjectListingsUpdated(
project,
() => { console.log(project) }
);
// Called when an event is published
const unsubscribeOnEventPublished = onEventPublished(
project,
(event) => { console.log(event) }
);