RealtimeStore – iOS
The RealtimeStore, a property of the Meeting class, allows you to set, get, and listen to value changes for specific keys shared across all participants in a meeting.
It provides a simple key–value storage system that stays synchronized in real time among all connected participants.
Methods
set()
The set() method is used to store or update data in the Realtime Store. If a key already exists, it will be overwritten with the new value. Passing nil as the value deletes the key.
Parameters
key(String) – The unique key under which the data will be stored.value(String?) – The value to be stored. Passnilto delete the key.
Throws
- An error if:
- Key is missing or not of type
String. - Payload size exceeds 1 KB per key.
- Session exceeds the 100-key limit.
- Request fails due to network or internal issues.
- Key is missing or not of type
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 from the Realtime Store.
Parameters
key(String) – The key whose value you want to retrieve.
Returns
String?— The stored value, ornilif the key does not exist.
Throws
- An error if:
- Key is missing or not of type
String. - Request fails due to network or internal issues.
- Key is missing or not of type
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 value of that key changes, the delegate method on your listener is triggered automatically for all participants.
Parameters
key(String) – The key to observe for changes.forListener(RealtimeStoreListener) – An object that conforms to theRealtimeStoreListenerprotocol.
Throws
- An error if the observer could not be set up.
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()
The stopObserving() method stops receiving updates for a previously observed key for a specific listener.
Parameters
key(String) – The key to stop observing.forListener(RealtimeStoreListener) – The listener to remove.
Throws
- An error if it fails to stop observing.
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)")
}
}
Got a Question? Ask us on discord

