Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register to Addressbook changes, using ABAddressBookRegisterExternalChangeCallback

I really need some help here.

I do exactly the same as in all the examples, but don't get any notification.

Here's my code:

 #import <AddressBook/ABAddressBook.h>
 #import <AddressBook/AddressBook.h>

Registering for notification:

ABAddressBookRef book = ABAddressBookCreate();
ABAddressBookRegisterExternalChangeCallback(book, addressBookChanged, self);

Definition of the callback:

void addressBookChanged(ABAddressBookRef reference, 
                        CFDictionaryRef dictionary, 
                        void *context) 
{

   ViewController *viewController = (ViewController*)context;
   [viewController addressBookChanged];    
}

And another method:

-(void) addressBookChanged
{
   NSLog(@"%@", @"addressBookChanged");
}
  • I'm running the app
  • Switching to the contacts app
  • Adding a new contact
  • nothing happens... no log, nothing...

What am I doing wrong here?

  • Any ' #import ' missing?
  • Should it work on device/simulator?
  • Any specific way of declaring the callback? Static maybe?

Any help will be appreciated. Thanks.

like image 901
Gal Avatar asked Jan 04 '12 15:01

Gal


1 Answers

Ok, I know the answer now...

The callback is being invoked, but only when I resume back my application.

like image 62
Gal Avatar answered Oct 21 '22 11:10

Gal