Inviting contacts works on iphone simulator but not on real device!
<p>I'm writing an iphone app. It involves inviting contacts from address book. My app works fine on the iphone simulator, but not on an actual device.</p>

<p>Here is the code:</p>

<pre><code>-(NSMutableArray*)getInfoContactList
{

    NSString *personName;
    NSMutableArray *arrayEmail = [[NSMutableArray alloc] init];
    NSMutableDictionary *pDicContactList;
    NSArray  *pArrObjectContact;
    NSArray  *pArrKeysContact = [NSArray arrayWithObjects:@"kName",@"kPhone",@"kEmail",@"kImage",nil];
    [m_pArrContactList removeAllObjects];

    // Fetch the address book
    ABAddressBookRef addressBook = ABAddressBookCreate();
    // get all people from the addressbook
    NSArray *people = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
    if ((people != nil) &amp;&amp; [people count]) {
        NSLog(@"%d contacts have been extracted from the address book", [people count]);
        for (int i=0;i &lt; [people count];i++)
        {
            ABRecordRef person = (ABRecordRef)[people objectAtIndex:i];
            //get name
            CFStringRef cfName = ABRecordCopyCompositeName(person);
            personName = [NSString stringWithString:(NSString *)cfName]; //ten trong danh ba
            CFRelease(cfName);

            //get phone number
            ABMultiValueRef phoneNumber = ABRecordCopyValue(person, kABPersonPhoneProperty);
            NSArray *arrPhone = (NSArray *)ABMultiValueCopyArrayOfAllValues(phoneNumber);
            if (!arrPhone) {
                arrPhone = [[NSArray alloc] init];
            }

            //get email
            ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
            NSArray *arrMailAdresses = (NSArray *)ABMultiValueCopyArrayOfAllValues(emails);
            if (!arrMailAdresses) {
                arrMailAdresses = [[NSArray alloc] init];
            }
            NSLog(@"contact %d  %@ has %d E-Mail addresses",i,personName,[arrMailAdresses count]);
            NSString *emailAddress = nil;
            for (int j=0;j &lt; [arrMailAdresses count];j++) 
            {
                emailAddress = (NSString *)[arrMailAdresses objectAtIndex:j];
                NSLog(@"address %d: %@", j, emailAddress);
                [arrayEmail addObject:emailAddress];
            }

            //get image
            UIImage *image = nil;
            if(ABPersonHasImageData(person))
            {
                image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(person)];
            }
            else
            {
                //default image in contact list
                NSString *path = [NSString stringWithFormat:@"%@",IMG_BKGR_VIEW];
                image = [UIImage imageNamed:path];

            }

            pArrObjectContact = [NSArray arrayWithObjects:personName,arrPhone,arrMailAdresses,image,nil];

            pDicContactList = [NSDictionary dictionaryWithObjects:pArrObjectContact forKeys:pArrKeysContact];
            [m_pArrContactList addObject:pDicContactList];

        }

    } 
    else 
    {
        NSLog(@"No contacts have been extracted from the address book");        
    }
    [people release];
    CFRelease(addressBook);
    return arrayEmail;
}
</code></pre>

<p>Any help for me? Thank so much!</p>
