Syncing Contacts
Once contacts access is granted, contacts are synced from the device to the cloud automatically without any action required from you.Automatic Sync
Contacts sync in small batches whenever the app is in the foreground. If Background Sync is enabled, contacts sync even when the app is not active. Even large contact books with 1000+ contacts sync in 60-90 seconds, depending on network conditions. For subsequent app launches, only unsynced or modified contacts are synchronized, ensuring minimal network and battery usage. The SDK automatically triggers sync when:- The app becomes active
- Contact store changes are detected
- Contact access status changes from denied to granted
Sync Metrics and Tracking
You can track the progress and results of contact syncing operations using platform-specific callbacks.SyncMetrics Structure
The SDK provides detailed metrics through theSyncMetrics
structure:
Force Sync
Sometimes you may need to force a complete resync of all contacts, regardless of their current sync status. This is useful when troubleshooting sync issues or ensuring data consistency after server-side changes.Implementation
Important Notes
- Performance Impact: Force sync processes ALL contacts, which may take longer than regular sync
- Network Usage: This operation will re-upload all contact data
- Use Sparingly: Only use when necessary, as regular incremental sync is more efficient
User Logout
When users log out of your application, you should properly clean up the ContactsManager service to ensure user data privacy and prepare for the next user session.When to Use Reset
- User Logout: When the current user signs out of your application
- Account Switching: When switching between different user accounts
Implementation
What Logout Does
- Clears Local Database: Removes all stored contact data for privacy
- Resets Sync State: Clears all sync timestamps and metadata
- Unsubscribes Events: Stops all background listeners and observers
- Clears User Session: Removes stored user tokens and preferences
- Service State: Returns the service to uninitialized state
Best Practices
- Initial Sync: After getting contacts authorization, let the automatic sync happen without interruption
- Completion Indication: Use the sync metrics to show progress to users when syncing large contact lists
- Background Sync: For the best user experience, enable Background Sync to keep contacts up-to-date even when the app is not active