Sync Phonebook Contact

Sync Contact#

warning

It will be only applicable for mobile number registration and contact book synchronization.

If mobile number is used as a primary id for communication in chat sdk then there has to be sync between user and server. The following code block initiate the contact sync and let the user communicate with their contacts who uses the client app too.

Note : In order to sync mobile contacts need to enable enableMobileNumberLogin in Mirrorfly.initializeSDK()

Mirrorfly.syncContacts(isFirstTime: !SessionManagement.isInitialContactSyncDone(), flyCallBack: (_) {
if(response.isSuccess){
}
});
ArgumentTypeDescription
IS_FIRST_TIMEbooleantrue for first time and false after when synchronising contacts
flyCallbackFlyResponsecallback to observe the action status

To observe contact sync events you can use this below method.

Mirrorfly.onContactSyncComplete.listen((event){
if (event as bool) {
// Contact Sync Success Reload Contact list
}
});

To avoid unnecessary multiple contact sync calls to get contact sync is already is in progress or not. use this before calling syncContacts

var isInProgress = await Mirrorfly.contactSyncStateValue();

The value of the contactSyncState can also be accessible by directly calling the get value method.