Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-27-2010, 09:25 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 1
*iPhoneDev* is on a distinguished road
Default Issues with ABAddressbokk since update to iOS 4.2

Hi,

I developed an app based on iOS 4.1, which manages the address book. However, since I have updated to iOS 4.2.1, I can't add a person to a group. However, it is still possible to add a group or a person to the address book.

XCode and SDK are up to date. There are apps in iTunes, which have exactly the same problem after the update, although most of them work still properly.
As I said, it worked with iOS 4.0 and iOS 4.1! Here is an example:

Code:
	ABAddressBookRef book = ABAddressBookCreate();
	ABRecordRef group = ABGroupCreate(); 
	ABRecordRef person = ABPersonCreate(); 
	ABRecordSetValue(group, kABGroupNameProperty, @"NewGroup", nil);
	ABRecordSetValue(person, kABPersonFirstNameProperty, @"Firstname", nil);
	ABAddressBookAddRecord(book, person, nil);
	ABAddressBookSave(book, nil);
	ABGroupAddMember(group, person, nil); //not working since update to iOS 4.2
	ABAddressBookAddRecord(book, group, nil);
	ABAddressBookSave(book, nil);
Does anyone have the same problem, or have any idea what's wrong here? For answers, I would be very grateful!

P.S.: forgive me for my bad english.
*iPhoneDev* is offline   Reply With Quote
Old 12-03-2010, 02:15 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 4
dpanzer is on a distinguished road
Default

Users of our app have been reporting similar issues - even with groups apparently created inside our app. Have you found any resolution?
dpanzer is offline   Reply With Quote
Old 12-03-2010, 09:00 PM   #3 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Jan 2010
Location: Issaquah, WA
Age: 42
Posts: 1,244
dljeffery is on a distinguished road
Default

According to the docs, "Before a person record can be added to a group, the record must be saved to the Address Book database."

This is actually not super-clear. But I copied the code from the OP's post into a sample project, saw it wasn't working for me either (on 4.2), and then decided that maybe the docs meant that the GROUP record had to be saved.

So I tried this slight modification, and it worked.

Code:
ABAddressBookAddRecord(book, group, nil);  // add the group record first!!
ABAddressBookSave(book, nil);  // also save the group record first!!
ABGroupAddMember(group, person, nil); // this works now!!
ABAddressBookSave(book, nil);
BTW, first thing I tried was passing in a CFErrorRef to see what the actual error was. Unfortunately ABGroupAddMember doesn't seem to care if you pass one in or not; it never got set to anything even when it was failing.
__________________
Recall It! Tag your notes. Tag your photos. Tag your thoughts. Tag your life.

Recall It! for iPad

http://www.dljeffery.com
dljeffery is offline   Reply With Quote
Old 12-05-2010, 12:53 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 1
felipezf is on a distinguished road
Default

Hi, a have the same problem when i updated from iOS 4.1 to 4.2.1. ABGroupAddMember always returns false on iOS 4.2.1, but on iOS 4.1 works. The Apple`s technical support said that it's a bug on iOS 4.2. I tried the code that you put here, but i didn' have success. Do you have another solution for this issue? I need solve this asap because I am almost finishing my app.

Thanks a lot!


Quote:
Originally Posted by dljeffery View Post
According to the docs, "Before a person record can be added to a group, the record must be saved to the Address Book database."

This is actually not super-clear. But I copied the code from the OP's post into a sample project, saw it wasn't working for me either (on 4.2), and then decided that maybe the docs meant that the GROUP record had to be saved.

So I tried this slight modification, and it worked.

Code:
ABAddressBookAddRecord(book, group, nil);  // add the group record first!!
ABAddressBookSave(book, nil);  // also save the group record first!!
ABGroupAddMember(group, person, nil); // this works now!!
ABAddressBookSave(book, nil);
BTW, first thing I tried was passing in a CFErrorRef to see what the actual error was. Unfortunately ABGroupAddMember doesn't seem to care if you pass one in or not; it never got set to anything even when it was failing.
felipezf is offline   Reply With Quote
Old 12-06-2010, 03:40 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 4
dpanzer is on a distinguished road
Default

I noticed the same instruction dljeffery pointed out in the docs, however I interpreted it differently, to mean that the person's record must be saved. I modified my code accordingly and everything worked again. Here is a concrete example:

Code:
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef testPerson = ABPersonCreate();
ABRecordSetValue(testPerson, kABPersonFirstNameProperty, @"test", NULL);

/*** WITHOUT THESE 2 LINES THE CALL BELOW WILL FAIL ***/
ABAddressBookAddRecord(addressBook, testPerson, NULL);
ABAddressBookSave(addressBook, NULL);
            
BOOL success = ABGroupAddMember(groupRec, testPerson, NULL);
this is assuming groupRec is an ABRecordRef pointing to a valid group. success will be true with the call to ABAddressBookAddRecord and ABAddressBookSave, but false without them. hope this helps

-danny
dpanzer is offline   Reply With Quote
Old 03-17-2011, 01:31 PM   #6 (permalink)
Beast Mode
 
Join Date: Dec 2008
Age: 21
Posts: 1,971
Bertrand21 is on a distinguished road
Default

Does anyone see how this is failing is iOS 4.2.1 and newer:

Code:
- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
	CFErrorRef error = nil;
	ABAddressBookSave(ab, nil);
	BOOL success = ABGroupAddMember(self.group.groupRecord, person, &error);
	
	if(success){
		//peoplePicker.prompt = @"Added";
		ABAddressBookSave(ab, nil);
		[self dismissModalViewControllerAnimated:YES];
		return NO;
	}
	else{
		CustomAlert *allert = [[CustomAlert alloc] initWithTitle:@"Error" message:@"This contact could not be added." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
		[allert show];
		[allert release];
	}
	return NO;
    [self dismissModalViewControllerAnimated:YES];
	
    
}
__________________
Haters gonna Hate
Likers gonna Like
Bertrand21 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 375
7 members and 368 guests
daudrizek, HemiMG, Kirkout, MarkC, Sami Gh, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:48 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0