Detecting Changes in Stored Contacts

,

Sometimes contacts may be modified outside of your app. You can use the ContactStore change tracking API to retrieve a list of changes that have occurred to contacts since a previous point in time.

To establish the current revision number of the contact store, retrieve the value of the ContactStore object’s RevisionNumber property. This is an unsigned long value that is updated whenever a contact is added or removed from the contact store, or whenever a contact is modified.

ContactStore store = await ContactStore.CreateOrOpenAsync();
ulong revisionCode = store.RevisionNumber;

You retrieve the list of changes since the last revision by calling the ContactStore class’s GetChangesAsync method. Each change record includes the Id and RemoteId of the StoredContact and the type of change that occurred. See the following excerpt:

IReadOnlyList<ContactChangeRecord> changes = await store.GetChangesAsync(revisionCode);
foreach (ContactChangeRecord change in changes)
{
    Debug.WriteLine("Record with ID {0} changed: {1}",
        change.Id, change.ChangeType);
}

The type of change is limited to one of three ContactChangeType enumeration values: Created, Deleted, or Modified.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.120.202