iPhone 地址簿外部回拨通知?

发布于 2024-11-24 04:38:07 字数 753 浏览 5 评论 0原文

在viewDidLoad中,我订阅了通知以获取外部回调通知。 如果我更改了 iphone 联系人中的任何内容,我不知道为什么我没有在应用程序中收到通知。

我正在这样做:

ab=ABAddressBookCreate();
ABAddressBookRegisterExternalChangeCallback(ab, MyAddressBookExternalChangeCallback, self);

并且我已经在同一个控制器中定义了它,

void MyAddressBookExternalChangeCallback ( ABAddressBookRef addressBook, CFDictionaryRef info, void *context ) {
 [((TGTextsInboxController *) context) addressBookHasChanged];
}

我如何调试它?我在模拟器中尝试过这种方式。

  1. 我打开我的应用程序到 TGTextsInboxController viewController
  2. 我按下主页按钮,我的应用程序进入后台
  3. 现在我已经打开 iPhone 联系人,更改了任何人的任何电话号码。
  4. 再次从后台打开应用程序到前台。
  5. 没有反映任何通知。调试器指针都没有命中此方法“MyAddressBookExternalChangeCallback”

有问题吗?

In viewDidLoad, I have subscribed to notifications to get external callback notifications.
I dont know why I am not getting notifications in my app if i have changed anything in my iphone contacts.

I am doing in this way:

ab=ABAddressBookCreate();
ABAddressBookRegisterExternalChangeCallback(ab, MyAddressBookExternalChangeCallback, self);

And I have defined this in same controller

void MyAddressBookExternalChangeCallback ( ABAddressBookRef addressBook, CFDictionaryRef info, void *context ) {
 [((TGTextsInboxController *) context) addressBookHasChanged];
}

How can I debug this ? I have tried in this way in Simulator.

  1. I opened my app upto TGTextsInboxController viewController
  2. I pressed home button, my app went in background
  3. nNow i have opened iPhone Contacts, changed any phone number of any person.
  4. Open app again from background to foreground.
  5. No notifications has been reflected. Neither degugger pointer hit to this method "MyAddressBookExternalChangeCallback"

Something wrong ?

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

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

发布评论

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

评论(2

风向决定发型 2024-12-01 04:38:07

问题已解决:

我在收到通知后发布了 CFRelease(ab);。我一评论那行。我能够收到通知。

Problem resolved:

I was releasing CFRelease(ab); after notification. As soon as i have commented that line. I am able to get notifications.

东走西顾 2024-12-01 04:38:07

使用地址簿回调。

void ABAddressBookRegisterExternalChangeCallback (
   ABAddressBookRef addressBook,
   ABExternalChangeCallback callback,
   void *context
);

我的样本 - 注册(创建 addressBookRef 后)

ABAddressBookRegisterExternalChangeCallback(addressBook, addressBookChanged, self);

我的 Smaple - 做一些事情和做一些事情取消注册

void addressBookChanged(ABAddressBookRef abRef, CFDictionaryRef dicRef, void *context) {

    NSLog(@"!!!!!Address Book Changed!");

    //Do Something You Need. (Recreate addressbook or Reload UITableView data.)

    ABAddressBookUnregisterExternalChangeCallback(abRef, addressBookChanged, context);
}

我的回答:
iPhone通讯录

Use addressBook call back.

void ABAddressBookRegisterExternalChangeCallback (
   ABAddressBookRef addressBook,
   ABExternalChangeCallback callback,
   void *context
);

My Sample - Register (After creating addressBookRef)

ABAddressBookRegisterExternalChangeCallback(addressBook, addressBookChanged, self);

My Smaple - Do Something & Unregister

void addressBookChanged(ABAddressBookRef abRef, CFDictionaryRef dicRef, void *context) {

    NSLog(@"!!!!!Address Book Changed!");

    //Do Something You Need. (Recreate addressbook or Reload UITableView data.)

    ABAddressBookUnregisterExternalChangeCallback(abRef, addressBookChanged, context);
}

My answer:
Iphone addressbook

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