修改联系人或添加电话号码时,永远不会调用修改过的案例
_contactStore.ContactChanged += _contactStore_ContactChanged;
private void _contactStore_ContactChanged(ContactStore sender, ContactChangedEventArgs args)
{
var defferal = args.GetDeferral();
ContactChangeReader reader = sender.ChangeTracker.GetChangeReader();
IReadOnlyList<ContactChange> changes = reader.ReadBatchAsync().AsTask().Result;
while (changes.Count != 0)
{
foreach (ContactChange change in changes)
{
switch (change.ChangeType)
{
case ContactChangeType.Modified: SomeLogic();
break;
}
}
changes = reader.ReadBatchAsync().AsTask().Result;
}
reader.AcceptChanges();
问题可能是ContactStoreAccessType
类型不正确。请尝试使用AllContactsReadWrite
枚举类型。
ContactStore store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadWrite);
store.ContactChanged += Store_ContactChanged;
private void Store_ContactChanged(ContactStore sender, ContactChangedEventArgs args)
{
}