gpt4 book ai didi

iOS - CNContactStoreDidChangeNotification 通知细节差异

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

如何获取iPhone通讯录的最新变化

我即将在我的 iOS 应用程序中集成联系人框架,并希望在外部(由其他应用程序或用户)更改联系人(在联系人中添加/编辑字段)时收到通知。我找到了 CNContactStoreDidChangeNotification 并想知道它是否会以有意义的形式带来联系人卡片中究竟发生了什么变化和/或关于哪个联系人发生了变化的信息。

这里找不到

最佳答案

目前,CNContactStoreDidChangeNotification 不提供更改。因此,如果您有一些缓存的联系人,则必须在收到通知时重新获取它们。

-(void)registerForCNContactStoreDidChangeNotification {
if (!self.hasRegisteredForNotifications) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(storeDidChange:) name:CNContactStoreDidChangeNotification object:nil];
self.hasRegisteredForNotifications = YES;
}
}

- (void)deviceContactsDidChange:(NSNotification *)notification {
// notification.userInfo can be nil

// need to fetch all contacts with enumerateContactsWithFetchRequest to get all contacts or
// refresh the cached contacts with unifiedContactsMatchingPredicate
}

Apple says

If you cache the fetched contacts, groups, or containers, you need to refetch these objects (and release the old cached objects) when CNContactStoreDidChangeNotification is posted.

关于iOS - CNContactStoreDidChangeNotification 通知细节差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53510196/

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