[IOS] - IOS 문자 보내기 Activity Intent, MFMessageComposeViewController

IOS ( Object-C ) 2014. 9. 11. 15:37
반응형

.h 파일


1. #import <MessageUI/MessageUI.h>

2. <MFMessageComposeViewControllerDelegate> 추가 


// 발송 화면 Intent

- (void) setSendMessage {

  if ([MFMessageComposeViewController canSendText]) {

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

    view.body = @"Sms Content";

    view.recipients = [NSArray arrayWithObject:@"01012345678"];

    view.messageComposeDelegate = self;


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

  }

}


// 창닫기, 전송완료시 호출

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

  [self dismissViewControllerAnimated:YES completion:nil];


  if (result == MessageComposeResultSent) {

    NSLog(@"Send");

  } else {

    NSLog(@"Cancel");

  }

}

반응형
: