A text post is the foundation of a social app. But we often see teams simplify the implementation to “TextField + Send button,” and then get complaints: a user wrote a long text, minimized the app — the draft was lost.
Or they sent a post on a weak internet connection — an error occurs, and everything must be redone. Our 5 years of development experience (30+ projects with content publishing) show that these details are critical for audience retention.
Another problem is version conflict: a user edits a post while another client is already changing the same draft. Without versioning, data is lost. Below is how we solve these tasks and what is included in the implementation.
How do we design a text editor?
In the minimal case, we use UITextView on iOS or BasicTextField on Android — if formatting is not required. We always include autocorrection, spell checking, and automatic height expansion up to 5–6 lines.
On iOS, this is configured via NSLayoutConstraint with updates in textViewDidChange. When formatting is needed (bold, italic, lists), the choice of stack depends on the platform:
| Platform | Tool | Features |
|---|---|---|
| iOS | UITextView + NSAttributedString or RichTextKit |
RichTextKit — open source, supports pasting, increases binary size by ~800 KB |
| Android | SpannableStringBuilder + EditText or Markwon |
Markwon is convenient for Markdown preview, lightweight |
| Flutter | flutter_quill |
Delta format, adds ~2 MB, requires server-side conversion |
It is recommended to store text on the backend in HTML or Markdown — neutral formats; the client converts them on load. This simplifies integration with the web version. Learn more about Markdown.
Why are drafts mandatory?
Users often leave the post creation screen unintentionally — a call, a notification, minimizing the app. Without draft saving, content loss is up to 40% (our tests across 30 projects).
We implement autosave with a 1–2 second debounce: every text change is written to UserDefaults (iOS) or DataStore (Android). The key is draft_post or draft_post_{channel_id} for multi-channel apps. When the editor opens, we check for a draft and offer to restore it.
After publishing or resetting, we clear it. On Flutter, we use SharedPreferences or Hive with debounceTime(Duration(seconds: 1)).
Once we implemented publishing in an app for bloggers. Users pasted long texts with formatting. We discovered that with autosave to UserDefaults on iOS, if the app is unloaded from memory, the draft is not saved. We switched to CoreData with a background context — saving reliability increased to 99%.
Example checklist for drafts
- [ ] Autosave with 1-2 sec debounce
- [ ] Restore on editor open
- [ ] Clear after publishing
- [ ] Multi-channel support
How to implement publishing with poor internet?
The standard approach is optimistic update + retry queue. When the user taps “Publish”:
- Generate a local
client_post_id(UUID). - Immediately add the post to the feed with
pendingstatus (gray indicator). - Send the request to the server. On success, replace the ID and remove the indicator.
- On error, show “Not sent” status with a “Retry” button.
On Android, for retries when network connectivity is restored, we use WorkManager with NetworkConstraint; on iOS, BGTaskScheduler or NWPathMonitor. This reduces the number of lost publications by 30–50% compared to synchronous sending. Comparison of approaches:
| Criterion | Synchronous publishing | Optimistic update |
|---|---|---|
| Response time for the user | 2-5 seconds on poor internet | Instant (local) |
| Data loss on error | 100% | 0% (post remains in pending) |
| Retry on network restoration | Manually | Automatically via WorkManager/BGTask |
Before deployment, we test offline scenarios: disabling the internet, switching modes, simulating a timeout. This helps identify race conditions and improve UX.
Validation and limits
We display the character limit with a counter (Twitter approach: red minus after exceeding). The publish button is active only when text.trimmingCharacters(in: .whitespacesAndNewlines).count > 0.
Mentions (@username) and hashtags (#tag) are parsed with regex and highlighted via NSAttributedString/AnnotatedString. Link pasting with automatic recognition is also supported.
What is included in the work
- Designing the post structure and API (GraphQL or REST specification)
- Implementing the editor with draft autosave
- Publishing logic with optimistic update and retry
- Error handling and retry on network restoration
- Content validation and counter display
- Testing offline scenarios on real devices with various OS versions
- API documentation and transfer of access (TestFlight, Google Play Console)
- Training the customer’s team and 1 month of support
Timeline and cost
Cost is calculated individually depending on complexity. Approximate timeline: a simple editor with drafts and retry — 2–3 days; with formatting and mentions — 5–7 days. For an accurate estimate, contact us — we will analyze the requirements and propose the optimal solution. Get a consultation: we guarantee quality and more than 5 years of experience.







