Here’s a comprehensive solution that addresses all three critical aspects of your sync reliability problem:
Offline Data Persistence:
First, enhance your SQLite configuration to ensure data durability during network transitions. In your mobile app configuration (app.config.json), update the offline storage settings:
offlineStorage: {
persistenceMode: "durable",
transactionIsolation: "serializable",
syncQueueRetention: "7days"
}
This ensures that queued operations persist even if the app crashes or network changes interrupt sync. The serializable isolation prevents partial commits that cause data inconsistency.
Implement a local validation layer before queuing sync operations. Add this check in your approval submission handler:
if (isOffline) {
validateApprovalData(approval);
persistToLocalDB(approval);
queueForSync(approval);
}
This validates data integrity before it enters the sync queue, preventing corrupted records from blocking the entire queue.
Network Change Handling:
The critical fix is implementing a network state monitor that pauses sync during network transitions. Create a custom network handler that integrates with AgilePoint’s sync service:
-
Network State Listener: Register a listener for network connectivity changes. When the network type changes (WiFi to cellular or vice versa), pause any active sync operations and wait for connection stability.
-
Connection Stability Check: Before resuming sync after a network change, verify connection stability by sending a lightweight ping to your AgilePoint server. Only proceed with sync if you get 2-3 consecutive successful pings.
-
Graceful Sync Interruption: If sync is interrupted mid-operation, mark the current operation as ‘retry pending’ rather than ‘failed’. This prevents the sync queue from getting stuck on a single failed operation.
Sync Queue Reliability:
Implement an intelligent retry mechanism with these components:
-
Exponential Backoff: Configure retry intervals that increase progressively: 30s, 1m, 2m, 5m, 10m. This prevents battery drain from aggressive retry attempts while ensuring eventual sync.
-
Operation Prioritization: Modify the sync queue to prioritize critical operations (like approvals) over less important data updates. Configure priority levels in your sync service:
syncPriority: {
approvals: 1,
comments: 2,
attachments: 3
}
-
Partial Sync Support: Enable the sync service to commit successfully synced items even if some operations fail. This prevents an all-or-nothing scenario where one bad record blocks 15 good approvals.
-
Sync Status Transparency: Add UI indicators showing:
- Number of pending operations in queue
- Last successful sync timestamp
- Current sync status (syncing/paused/error)
- Network connection quality
This gives users confidence that their offline work is safely queued and will sync when conditions are right.
Implementation in AgilePoint Mobile SDK:
Extend the default sync behavior by creating a custom SyncManager class that wraps AgilePoint’s native sync service. Override these key methods:
onNetworkChange(): Pause/resume sync based on connection stability
onSyncError(): Implement smart retry logic instead of immediate failure
validateSyncQueue(): Check queue integrity before each sync attempt
commitPartialSync(): Allow partial success rather than all-or-nothing
Testing Strategy:
Test this solution by simulating real-world network conditions:
- Approve 15 POs while completely offline
- Switch from WiFi to airplane mode to cellular while sync is in progress
- Force-close the app during sync
- Verify all operations eventually sync successfully
With these changes, your mobile approvers should experience zero data loss regardless of network conditions. The sync queue becomes resilient to interruptions, and offline data persists reliably until it can be safely transmitted to the server.