[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Linphone-developers] importing contacts

From: Стоян Ангелов
Subject: Re: [Linphone-developers] importing contacts
Date: Tue, 17 Oct 2017 21:35:27 +0300 (EEST)


I'm actually a casual Linphone user who just uses the standard Linphone. I don't have much experience in coding. Is there an easier way? Thanks anyways!

>-------- Оригинално писмо --------
>От: Ruchi Agrawal address@hidden
>Относно: Re: [Linphone-developers] importing contacts
>До: address@hidden, address@hidden
>Изпратено на: 17.10.2017 20:40


If you are using ABAddressBook for fetching phone contacts you can use method “ ABAddressBookCopyArrayOfAllPeople
then sort all the contacts with predefined predicate rules and save them in an array, 

here is code for your detail understanding 

 CFArrayRef peopleRefs = ABAddressBookCopyArrayOfAllPeople(addressBook);

    CFMutableArrayRef mutablePeopleRefs = CFArrayCreateMutableCopy(kCFAllocatorDefault, CFArrayGetCount(peopleRefs), peopleRefs);


    CFArraySortValues(mutablePeopleRefs, CFRangeMake(0, CFArrayGetCount(mutablePeopleRefs)), (CFComparatorFunction) ABPersonComparePeopleByName, (void*) (long) kABPersonSortByFirstName);

    sortedAddressBook = (__bridge NSMutableArray *)(mutablePeopleRefs);


    //make a 27key values array including alphabatic and #.

    //make 27 sections on basis of thes keys

    //give sectionTitle from this array.

    //put values in corrosponding sections from sortedContacts.


    indexArray =[[NSArray alloc] initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",@"#",nil];

    keyContactsDictonary = [[NSMutableDictionary alloc]init];

    for (int i = 0; i<[indexArray count]; i++) {

        NSString *sectionKey = [indexArray objectAtIndex:i];

        NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id record, NSDictionary *b)


                                      ABRecordRef recordRef = (__bridge ABRecordRef)record;

                                      NSString *name=(NSString *)CFBridgingRelease(ABRecordCopyCompositeName(recordRef));

                                      if ([name hasPrefix:sectionKey] || [name hasPrefix:[sectionKey lowercaseString]]) {

                                          return YES;


                                      return NO;


        NSArray *tempArray = [sortedAddressBook filteredArrayUsingPredicate:predicate];

        [keyContactsDictonary setValue:tempArray forKey:sectionKey];

Thanks & Regards
Ruchi Agrawal

On Tue, Oct 17, 2017 at 2:10 AM, Стоян Ангелов <address@hidden> wrote:

I've just installed Linphone as my softphone. I've got quite a large contacts list and importing them one by one would take too much time. Is there a way to import all of them at once? Thanks!

Linphone-developers mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]