Skip to main content
Use PostRepository.getPost(postId) to retrieve a single post as a live object, or PostRepository.getPosts(postIds) to retrieve multiple posts by ID. Both return live objects or live collections that update automatically when the underlying data changes.

Overview

Live Objects

Posts are returned as live objects that automatically update when data changes

Comprehensive Data

Retrieve complete post information including content, reactions, comments, and metadata

Single Post Retrieval

Retrieve a specific post by its unique identifier with complete post information and real-time updates.
var token: AmityNotificationToken?

func getPostByIdExample() {
    token = postRepository.getPost(withId: "<post-id>").observe { liveObject, error in
        // Observer block, Do something here
    }
}

Multiple Posts Retrieval

Retrieve multiple posts by their IDs in a single operation with live collection updates.
var token: AmityNotificationToken?

token = postRepository.getPosts(postIds: ["post-id-1", "post-id-2"]).observe { collection, error in
    // Observe live collection here
}