Comments system in mobile app

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Comments system in mobile app
Medium
~2-3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Developing a Comments System in a Mobile App

Comments are more complex than likes in many ways: nesting (or lack thereof by design), pagination, keyboard overlapping input field, @mentions within text, moderation. Most common complaint on custom implementations — "comments scroll jumps" or "keyboard covers last comment." Let's start with exactly that.

Keyboard Problem

On iOS UITableView or UICollectionView with comment list + UITextField at bottom. When keyboard appears, need to raise all content. Correct way — don't touch contentInset manually, use KeyboardLayoutGuide (iOS 15+): view.keyboardLayoutGuide.topAnchor.constraint(equalTo: inputView.bottomAnchor). On iOS 14 and below — subscribe to UIResponder.keyboardWillShowNotification and update tableView.contentInset.bottom.

After adding new comment — scroll to it: tableView.scrollToRow(at: lastIndexPath, at: .bottom, animated: true). Problem: if scrollToRow called before UITableView processes insertion (insertRows(at:with:)), crash on NSInternalInconsistencyException. Order: first beginUpdates → insertRows → endUpdates, then scrollToRow.

On Android with Compose — LazyColumn with reverseLayout = true (new messages at bottom) and imePadding() at column level. reverseLayout eliminates manual scroll down on comment add.

Data Structure and Nesting

Flat structure (all comments on same level) — simpler and works for most apps. Instagram does it: one comment level + replies via separate request.

If nesting needed: store parent_comment_id (nullable). Display maximum 2 levels — deeper not read. Load replies lazy: by default show "N answers," on tap load.

Pagination — cursor-based: GET /posts/{id}/comments?cursor=<last_id>&limit=20. For nested replies — separate endpoint GET /comments/{id}/replies.

Adding Comment

Optimistic add — mandatory. Locally generate client_comment_id, add to list with isPending = true, show spinner or gray text. On success — replace with server object. On error — show "Retry" button next to comment.

Input field — UITextView with auto-expansion (not UITextField): comments are often long. Limit 500-1000 characters with counter. Send button — active on non-empty text.

Deletion and Moderation

Delete own comment — swipe (iOS) or long-tap with bottom sheet. Don't remove deleted comment completely if it has replies — replace text with "Comment deleted." Otherwise child replies lose context.

Report comment — report_comment_id → moderation queue. Auto-hide on N reports (configurable) + manual review.

Comment Counter in Feed

Denormalized field comments_count in post table, incremented/decremented by trigger or queue. On comment add via app — update counter in UI optimistically.

Timeline

Flat comments with pagination, optimistic add, deletion — 2-3 business days. With nested replies, mentions, moderation — 5-7 days. Cost calculated individually.