HOW TO SEND MESSAGES IN IPHONE

Lillian Martin

Total Post:27

Points:189
Posted by  Lillian Martin
iPhone  Ios 
 772  View(s)
Ratings:
Rate this:
How to send messages in iPhone ?
  1. Allen Scott

    Post:46

    Points:324
    Re: How to send messages in iPhone

    Few steps will led u to understand the simple implementation involved in it:

     

    Step.1-Include  MessageUI.framework in your project.


    Step-2 Import  MessageUI/MessageUI.h in your header file like that in my case.

    #import <MessageUI/MessageUI.h>

    #import <UIKit/UIKit.h>

    #import <QuartzCore/QuartzCore.h>

     

    @interface SendSMS : UITableViewController<MFMessageComposeViewControllerDelegate>

    @property (retain, nonatomic) NSString *SMSSubject;

    @end

     

    Setp-3 Suppose you want to send SMS on button  touch(click) then write the following code in your implementation (SendSMS.m) file.

     

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

         controller.messageComposeDelegate = self;

     

    // CHECK DEVICE CAN SEND TEXT MESSAGE. 

        if([MFMessageComposeViewController canSendText]){

    // message subject.

           controller.subject=@this is message subject. ;

    //  message body

        controller.body=[NSString stringWithFormat:@ This is the testing message. ];


    // contact number you want to send .

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

            

    // check the condition in case of model view controller is not dismissed.

                    if (![[self presentedViewController] isBeingPresented]) {

                        [self dismissViewControllerAnimated:YES completion:nil];

                     

                    }

    // show message view  UI.

    [self presentViewController: controller animated:YES completion:nil];

                }

     

    // delegate method of  MFMessageComposeViewController .


    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result

    {

          [controller dismissViewControllerAnimated:YES completion:nil];

    }

      Modified On Feb-19-2015 01:37:30 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!