- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
如何获取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
}
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/
如何获取iPhone通讯录的最新变化 我即将在我的 iOS 应用程序中集成联系人框架,并希望在外部(由其他应用程序或用户)更改联系人(在联系人中添加/编辑字段)时收到通知。我找到了 CNContact
当应用程序处于后台状态时更改联系人数据库时,我能够观察到 CNContactStoreDidChangeNotification。我很确定只有一个观察者被添加到 NSNotificationCente
当应用程序处于后台状态时更改联系人数据库时,我能够观察到 CNContactStoreDidChangeNotification。我很确定只有一个观察者被添加到 NSNotificationCente
我想要获取所有新添加的联系人标识符。 这是我的代码: -(void)viewWillAppear:(BOOL)animated { [[NSNotificationCenter default
我使用通讯录联系人制作了应用。 问题:-我从通讯录更新/添加/删除联系人,然后返回到我的应用程序。 我的应用程序 applicationDidBecomeActive 主动编写以下代码:- Notif
我是一名优秀的程序员,十分优秀!