social.plus SDK provides the getLatestComment method to fetch the most recent comment for any reference within your application. This feature enhances user experience by keeping users informed about the latest interactions and fostering a more dynamic, interactive environment with real-time updates.

Live Object Integration

Returns live objects that automatically update when new comments arrive

Optimized Queries

Efficient single-comment retrieval with minimal network overhead
The getLatestComment method returns a Live Object that you can observe for real-time updates when Realtime Events are subscribed, ensuring your app stays current with the latest community interactions.

Parameters

ParameterTypeRequiredDescription
referenceIdStringYesID of the reference (post, story, etc.)
referenceTypeEnumYesType of reference (e.g., .post, .story)
includeRepliesBooleanNoWhether to include reply comments (default: false)
var token: AmityNotificationToken?

func getLatestCommentExample() async {
    do {
        let comment = try await commentRepository.getLatestComment(
            withReferenceId: "<post-id>",
            referenceType: .post,
            includeReplies: true
        )
    } catch {
        // Handle error here
    }
}