Getting and displaying Events
Getting and displaying Events
func displayActiveEvent(in project: Project) {
// If left unspecified, the `getEvents` function would use
// the project you setup in the SDK by calling `configure()`
project.getEvents { result in
do {
let events = try result.get()
// You can find an active event by checking it's state
guard let firstActiveEvent = events.first(where: { $0.state == .active }) else {
return
}
// You can fetch some of its properties
// And display them in your UI as you see fit
let id = firstActiveEvent.id
let myField = firstActiveEvent.fields["my field"]
let eventName = firstActiveEvent.name
let eventFinishDate = firstActiveEvent.endAt
} catch {
// Treat the error
}
}
}Last updated

