AmityObject<T> and live collections with AmityCollection<T>. Both are ObservableObjects and expose published state for SwiftUI or Combine. Block observation is tied to AmityNotificationToken; retain the token while you need updates.
Platform Surface
Parameters And State
Observe A Live Object
This example observes one post. Keeptoken in view-controller, view-model, or view scope; invalidate it when the screen disappears.
Observe A Live Collection
AmityCollection emits through snapshots. Use pagination methods on the collection instance, not array indexing helpers from older SDK generations.
Observe Published Snapshots
AmityObject and AmityCollection are also observable from SwiftUI or Combine through published properties.
Notes
- Current iOS SDK live objects expose
snapshot; live collections exposesnapshots. - Do not use older
object,object(at:), orcount()patterns with current live objects and collections. - Observer callbacks are dispatched on the main thread.
- If an object has local data, the SDK can emit local state before fresh server state.
- For fresh-only flows, wait until
dataStatus == .fresh, then invalidate the token if you do not need future updates. - For SwiftUI, pass the live object or collection directly into the view that observes it. Nested
ObservableObjectcontainers can hide changes from SwiftUI.
Related Topics
Post Retrieval
See post-specific iOS retrieval examples.
Realtime Events
Learn how server events keep SDK state fresh.