Menu

1 / 5

Cloud Save on Android and iOS: The Merge Rule That Never Loses Progress

DEV Community: kotlin·Nesim Razon·1 day ago
#aiRUcxU6
#devtokotlin#devto#dev#cloud#stars
Reading 0:00
15s threshold

Players change phones and reinstall apps, and they expect their stars to come with them. We wanted cloud save in our new game from the first release, on both Android and iPhone, without a server and without a conflict dialog. The trick is a merge rule so simple that it fits in one line, and a shared piece of Kotlin that both platforms call.

Two stores, one format

On Android the progress lives in Play Games Saved Games. On iPhone it lives in the iCloud key-value store. They have nothing in common technically, so the shared code does not touch either. It only knows how to turn progress into a small text blob, how to read a blob back, and how to merge two of them.

The blob has one entry per line in the form key, a vertical bar, and an integer, sorted by key. Door stars, level stars, unlocked doors and one total counter go in.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.