Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get birthday list contacts from iphone

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef nameArray = ABAddressBookCopyArrayOfAllPeople (addressBook);

m_SourceContactsUserArray = [[NSMutableArray alloc] init];
for (int i = 0; i<CFArrayGetCount(nameArray); i++) {
    ABRecordRef person = CFArrayGetValueAtIndex(nameArray, i);
    NSString *personName = (NSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty);
    [m_SourceContactsUserArray addObject:personName];
}
CFRelease(addressBook);
CFRelease(nameArray);
like image 931
Rock Avatar asked Apr 17 '12 12:04

Rock


People also ask

Why are my Contacts Birthdays not showing in calendar iPhone?

Do you see your contacts' birthdays on your Calendar app at all? If not, from the Calendar app, tap Calendars at the bottom of the screen, then select Birthdays. Then, from Settings > Calendar > Default Alert Times, check to see what is selected for Birthdays.

How do I get birthday notifications on my iPhone Contacts?

Open the Contacts App on your iPhone and tap on the Contact for which you want to setup birthday alerts on iPhone. On the Contact's detail screen, tap on the Edit option located at the top right corner of your screen. Next, scroll down and tap on + Add Birthday option.

How do I find my birthday Contacts?

Birthdays come from details in your Google Contacts. Tip: If the person is in your Google Contacts, you can edit or remove the person's birthday from the People or Contacts app on your phone, or from google.com/contacts. Settings. Under "More," tap Birthdays.


1 Answers

Try this code:

ABAddressBookRef myAddressBook = ABAddressBookCreate();
NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(myAddressBook);

for (id record in allPeople) {
    NSMutableDictionary *newRecord = [[NSMutableDictionary alloc] init];
    CFTypeRef bDayProperty = ABRecordCopyValue((ABRecordRef)record, kABPersonBirthdayProperty);

    if (ABRecordCopyValue((ABRecordRef)record, kABPersonBirthdayProperty)) 
           {
        NSDate *date=(NSDate*)bDayProperty;
        [newRecord setObject:date forKey:@"birthDate"];
        date=nil;
        [date release]; 
    }
   CFRelease(myAddressBook);
 }

it will help you.

like image 157
Dhaval Bhadania Avatar answered Oct 23 '22 06:10

Dhaval Bhadania