未检测到已删除的条目 - iOS

发布于 2024-11-11 13:35:46 字数 491 浏览 7 评论 0原文

是否可以从应用程序内检测已删除地址簿条目(例如从 iOS 电话簿本身)?

我有一个应用程序需要将 iOS 地址簿数据库的本地副本与手机中的地址簿同步。该应用程序支持支持后台模式的 iOS。

在后台支持的 iOS 环境中测试应用程序我的问题如下:
应用程序不会检测到系统通讯簿中已删除的条目,直到应用程序完全关闭(iOS 4用跳板中的红色 X 杀死它)。如果应用程序只是发送到后台,则从系统地址簿中删除联系人,然后应用程序再次将其带到前台,已删除条目 id 的函数 ABRecordRef() 不会像条目所预期的那样返回 NULL如果它不再存在,它会返回该条目,就好像它从未从系统地址簿数据库中删除一样。

如上所述 - 如果应用程序完全终止并重新启动,则已删除 ID 的 ABRecordRef() 将按预期工作 - 它返回 NULL。有没有什么方法可以检测到这个已删除的条目,而无需等待应用程序被杀死并重新启动?

Is it possible to detect deleted Address Book entries (for example from the iOS phonebook itself) from within an application?

I have an application which needs to synchronize a local copy of the iOS Address Book database with the Address book from the phone. The application supports background mode on iOSes which support it.

Testing the application in a background capable iOS environment my problem is the following:
The application does not detect an entry which has been deleted in the system address book until the application is closed completely (iOS 4 killing it with the red X in springboard). If the application is simply sent to the background, a contact is deleted from the system address book, and then the app brought to the foreground again the function ABRecordRef() for the deleted entry id does not return NULL as would be expected for an entry which no longer exists, it returns the entry as if it had never been removed from the system address book database.

As above - if the application is completely terminated and restarted then ABRecordRef() for the deleted id works as expected - it returns NULL. Is there any way to detect this deleted entry without waiting for the app to be killed and restarted?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朮生 2024-11-18 13:35:47

是的。使用ABAddressBookRegisterExternalChangeCallback 注册地址簿的更改,例如

// Your method called when the user has granted access to their address book data.
- (void)accessGrantedForAddressBook
{
    ABAddressBookRegisterExternalChangeCallback(sharedAddressBook, MyAddressBookExternalChangeCallback, (__bridge void *)(self));
}

,其中MyAddressBookExternalChangeCallback 是您的回调函数。

Yes. Register for changes to the address book with ABAddressBookRegisterExternalChangeCallback, e.g.

// Your method called when the user has granted access to their address book data.
- (void)accessGrantedForAddressBook
{
    ABAddressBookRegisterExternalChangeCallback(sharedAddressBook, MyAddressBookExternalChangeCallback, (__bridge void *)(self));
}

Where MyAddressBookExternalChangeCallback is your callback function.

蓦然回首 2024-11-18 13:35:47

我相信每次刷新地址簿中的数据时都需要创建一个新的 ABAddressBook。原因是这样的:

您可能已经在地址簿副本中添加、更新和删除了记录,但尚未调用“保存”或“恢复”。因此,如果系统(例如iOS内置的通讯录应用程序)更改了地址簿中的内容,您将无法自动获取它们。

尝试运行“恢复”或重新创建地址簿,它应该可以工作。

I belive that you need to create a new ABAddressBook every time you refresh data from the address book. The reason is this:

You might have added, updated and removed records in your copy of the address book but not yet called Save or Revert. Hence, if the system (e.g. iOS build in contact book app) changes things in the address book, you cannot get them automatically.

Try either running Revert or to recreate the addressbook and it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文