Skip to main content
Version: 2.0.x

Realtime Store - iOS

The Realtime Store allows you to store, update, retrieve, and observe custom key-value data within a meeting — in real time. It acts as a shared data layer across all connected participants, ensuring synchronized states throughout the session.

This is particularly useful for collaborative or stateful meeting experiences such as:

  • Pinned messages and flags
  • Moderation data (e.g., blocked users)
  • Collaborative notes or polls

set()

The set() method is used to store or update data in the RealtimeStore. If a key already exists, it will be overwritten with the new value. Passing nil as the value deletes the key.

Key Notes

  • Supports String values only.
  • Each key can store up to 1 KB of data.
  • A maximum of 100 keys are allowed per session.
  • Deletion is performed by setting the value to nil.
  • Throws an error if:
    • The key is missing or not of type String.
    • The request fails.
    • The session exceeds the 100-key limit.

Parameters

  • key (String)
    The unique key to store the data under.

  • value (String?)
    The string value to be stored. Pass nil to delete the key.

Example

let REALTIME_STORE_KEY = "Blocked_Students"
Task {
do {
try await meeting.realtimeStore.set(key: REALTIME_STORE_KEY, value: "[Deep,Lily]")
print("Data set successfully!")
} catch {
print("Failed to set data: \(error.localizedDescription)")
}
}

get()

The get() method retrieves the current value associated with a given key.

Key Notes

  • Returns the current string value for the given key.
  • Useful for fetching shared state when joining a meeting or reloading a view.
  • Throws an error if the key is missing or if the request fails.

Parameters

  • key (String) The key whose value you want to retrieve.

Returns

  • String? — The stored value or nil if the key does not exist. The method throws an error on failure.

Example

let REALTIME_STORE_KEY = "Blocked_Students"
Task {
do {
let value = try await meeting.realtimeStore.get(key: REALTIME_STORE_KEY)
let displayValue = value ?? "nil (key not found)"
print("Current value: \(displayValue)")
} catch {
print("Failed to get data: \(error.localizedDescription)")
}
}

observe()

The observe() method subscribes to real-time updates for a given key. When the key’s value changes, a delegate method on your listener is automatically triggered for all connected participants.

Key Notes

  • You register a listener object that conforms to the RealtimeStoreListener protocol.
  • The delegate method receives the new value and information about who updated it.
  • Ideal for syncing live data like timers, shared notes, or agendas.

Parameters

  • key (String) The key to observe.

  • forListener (RealtimeStoreListener) An object that conforms to the RealtimeStoreListener protocol to receive updates.

Example

First, conform to the RealtimeStoreListener protocol:

extension MeetingViewController: RealtimeStoreListener {
func onValueChanged(key: String, value: String?, updatedBy: String) {
print("RealtimeStore Value Changed - Key: \(key), Value: \(value ?? "nil"), UpdatedBy: \(updatedBy)")
}
}

Then, start observing:

let REALTIME_STORE_KEY = "Blocked_Students"
Task {
do {
try await meeting.realtimeStore.observe(key: REALTIME_STORE_KEY, forListener: self)
print("Started observing key successfully!")
} catch {
print("Failed to observe key: \(error.localizedDescription)")
}
}

stopObserving()

Stops receiving updates for a specific key and listener combination.

Key Notes

  • Should be called when the listener is no longer needed (e.g., when the view controller is deallocated).

Parameters

  • key (String) The key you want to stop observing.

  • forListener (RealtimeStoreListener) The listener that should stop receiving updates.

Example

let REALTIME_STORE_KEY = "Blocked_Students"
Task {
do {
try await meeting.realtimeStore.stopObserving(key: REALTIME_STORE_KEY, forListener: self)
print("Stopped observing successfully!")
} catch {
print("Failed to stop observing: \(error.localizedDescription)")
}
}

Error Handling & Constraints

PropertyDescription
Error HandlingAll RealtimeStore methods are async throws; wrap them in do-try-catch.
Payload SizeMaximum 1 KB per key.
Supported TypeOnly String values are supported. Use nil to delete key.
ConcurrencyThe latest write overwrites previous values (last write wins)
Key LimitA maximum of 100 keys are allowed in a single session.

API Reference

The API references for all the methods utilized in this guide are provided below:

Got a Question? Ask us on discord