简体   繁体   中英

how can i access iphone contacts from my app?

I want to send a SMS from my application. For that,i use MFMessageComposeViewController and "messageui.framework" and is working greatly. But for that i gave the number of receiver in code. Actually,i want to add contact from phonebook. How can i get the desired contact in my application at the time of sending sms using MFMessageComposeViewController ?

Suppose my code is below and i dont understand how can i give contact number from my contacts in picker.recipients.Please help me as i want to select the contact number from contacts to send sms from my application.

-(void)ComposerSheet 
{
    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
    picker.messageComposeDelegate = self;

    picker.recipients = [NSArray arrayWithObject:@"1234567890"];  
    picker.body = @"I am at %@";

    [self presentModalViewController:picker animated:YES];
    [picker release];

}

When we are using MFMessageComposeViewController , then it automatically gives the link of contacts. So no need of AddressBookUI Framework required in this case. In MFMessagecomposeViewController , contacts have to be added by clicking the "+" button on the right side of the add recipients field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM