Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

sms in app

hello everyone was wondering if i could get some feed back on how to communicqate with other members in my app with sms - (void)showSMS:(NSString*)file {

if(![MFMessageComposeViewController canSendText]) {
    UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [warningAlert show];
    return;
}

NSArray *recipents = @[@"12345678", @"72345524"];
NSString *message = [NSString stringWithFormat:@"Just sent the %@ file to your email. Please check!", file];

MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
[messageController setRecipients:recipents];
[messageController setBody:message];

// Present message view controller on screen
[self presentViewController:messageController animated:YES completion:nil];

}

2 Answers

Alex Hedley
Alex Hedley
16,381 Points

Did you import the framework

MessageUI 

App Coda have just published an article on this:

http://www.appcoda.com/ios-programming-send-sms-text-message/

yes i saw that this is how i starrted my questio as in how to sms members within the app. If you look at the code provided in the appcoda looks like i would need the phone number of the recipents and i dont think the members of my social app would give that info to other members . I was wondering if ther might be another way to link the recipents of other iphones using the same app without using there phone number.