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
.
3.17.78.157