imessagexcode1

Adding iMessage Support to iOS Apps

Posted on in Blog, Technology

Here’s few steps on how to add iMessage support to your Xcode project:

Step 1: Add “MessageUI.framework” into your Xcode Project

 

 

 

 

 

Step 2: Call the function in your ViewController.m file like so:   #import “MessageUI/MessageUI.h”

Step 3: This code goes into your ViewController.m file:

-(IBAction) sendInAppSMS:(id) sender

{

MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];

if([MFMessageComposeViewController canSendText])

{

controller.body = @”Hello from  Andriy Kharkovyy”;

controller.recipients = [NSArray arrayWithObjects:@"1232221111", nil];

controller.messageComposeDelegate = self;

[self presentModalViewController:controller animated:YES];

}

}

Step 4: Beneath that allow for the action to be terminated like so:

- (void) messageComposeViewController:(MFMessageComposeViewController *)

controller didFinishWithResult:(MessageComposeResult)result

{

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”MyApp” message:@”Unknown Error”

delegate:self cancelButtonTitle:@”OK” otherButtonTitles: nil];

switch (result) {

case MessageComposeResultCancelled:

NSLog(@”Cancelled”);

break;

case MessageComposeResultFailed:

[alert show];

break;

case MessageComposeResultSent:

break;

default:

break;

}

[alert release];

[self dismissModalViewControllerAnimated:YES];

}

 

That’s about it.

Tagged , , , , , , , ,

One Response to 'Adding iMessage Support to iOS Apps'

  • thanks for the tip

    john

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>