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.