Cloud sync enables sharing bookmarks, notes, highlights, reading progress, and history across devices. Uses a delta-based protocol over REST with Firebase Cloud Messaging (FCM) for push notifications.
Alkitab/src/main/java/yuku/alkitab/base/sync/Sync.java— Core sync engine with generic delta frameworkAlkitab/src/main/java/yuku/alkitab/base/sync/SyncAdapter.java— WorkManager-based worker executing syncAlkitab/src/main/java/yuku/alkitab/base/sync/Sync_Mabel.java— Markers, labels, marker-label syncAlkitab/src/main/java/yuku/alkitab/base/sync/Sync_Pins.java— Progress marks syncAlkitab/src/main/java/yuku/alkitab/base/sync/Sync_Rp.java— Reading plan progress syncAlkitab/src/main/java/yuku/alkitab/base/sync/Sync_History.java— Reading history syncAlkitab/src/main/java/yuku/alkitab/base/sync/Fcm.java— FCM token managementAlkitab/src/main/java/yuku/alkitab/base/sv/FcmMessagingService.kt— FCM message handlerAlkitab/src/main/java/yuku/alkitab/base/sync/SyncRecorder.java— Sync event loggingAlkitab/src/main/java/yuku/alkitab/base/sync/SyncKotlin.kt— Kotlin wrapper for scheduling
POST /sync/api/sync
simpleToken— authentication tokeninstallation_id— device identifierfcm_token— Firebase token for push- Per entity type:
base_revno(last known revision) +delta(local changes)
- Per entity type:
append_delta(server changes since base_revno) - New
revnoto use as next base
Each delta entry is an operation tuple: (kind, gid, content) where:
kind= entity type identifiergid= globally unique IDcontent= entity data (null for deletions)
Operations: add, mod, del
The sync uses a shadow table (SyncShadow) to track the last-synced state. When applying server deltas:
- If the entity hasn't changed locally since last sync → apply server version
- If the entity changed locally → server wins (last-write-wins for most fields)
- Partial sync threshold: 100 operations per batch
When a sync completes on one device, the server sends an FCM message to other registered devices. FcmMessagingService receives the push and triggers a sync via SyncAdapter.
FCM configuration differs between debug (uses RIBKA_FUNCTIONS_HOST_DEBUG at 10.0.3.2:5001) and release builds.
Simple token-based auth stored in Prefkey.sync_simpleToken. Login flow is handled by SyncLoginActivity.
- SyncShadow — stores the last-synced state of each entity for conflict detection
- SyncLog — audit log of sync operations for debugging (viewable in
SyncLogActivity)