gpt4 book ai didi

ios - 如何从 ABAddressBookRegisterExternalChangeCallback 获取更新的联系人列表?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:11:02 25 4
gpt4 key购买 nike

我正在使用 ABAddressBookRegisterExternalChangeCallback 在 ios 通讯簿联系人更改时获取通知。

如何从回调中获取更新(添加/删除/修改)的联系人列表?我不想再次重新加载我的整个联系人列表。

我似乎无法在文档中的任何地方找到它。谁能指导我,该怎么做?

最佳答案

你不能。您可以做的是这将为您提供“在给定时间内修改”的联系人列表,例如:

void MyAddressBookExternalChangeCallback (ABAddressBookRef notifyAddressBook,CFDictionaryRef info,void *context)
{
//The addressbook object get's updated.


CFArrayRef peopleRefs = ABAddressBookCopyArrayOfAllPeopleInSource(notifyAddressBook, kABSourceTypeLocal);



ABAddressBookRevert(notifyAddressBook);

CFIndex count = CFArrayGetCount(peopleRefs);

for (CFIndex i=0; i < count; i++) {
ABRecordRef ref = CFArrayGetValueAtIndex(peopleRefs, i);
NSDate* datemod = (__bridge_transfer NSDate *)(ABRecordCopyValue(ref, kABPersonModificationDateProperty));


NSTimeInterval distanceBetweenDates = [[NSDate date] timeIntervalSinceDate:datemod];

int seconds = round(distanceBetweenDates);

if(seconds < 60){

ABCPerson * person = [[ABCFacade sharedABCFacade] convertABRecordRef:ref];
NSLog(@"modifactiondate: %@", [person modificationdate]);

[[ABCFacade sharedABCFacade] replacePersonInPersonListWithPerson:person];

}
}


NSLog(@"Yes it does get called by this change %@", context);

[[ABCFacade sharedABCFacade] ABRefresh];
}

关于ios - 如何从 ABAddressBookRegisterExternalChangeCallback 获取更新的联系人列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15495621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com