首页 > 代码库 > iOS 调用带内容的短信页面

iOS 调用带内容的短信页面

- (void)inviteBtnMethod

{

    NSLog(@"inviteBtnMethod  %@",myInviteCode.text);

  //  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];

    NSString *str = @"我邀请你参与新鲜,新鲜是一个独立的模特平台。帮你找到更多的工作,注册时候用我的邀请码";

    NSString *inviteMessage = [NSString stringWithFormat:@"%@%@",str,myInviteCode.text];

    [self sendSMS:inviteMessage recipientList:nil];

//     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];

    

}

- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients

{

    NSLog(@"bodyOfMessage-< %@",bodyOfMessage);

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

    

    if([MFMessageComposeViewController canSendText])

        

    {

        

        controller.body = bodyOfMessage;

        

        controller.recipients = recipients;

        

        controller.messageComposeDelegate = self;

        

        [self presentModalViewController:controller animated:YES];

        

    }

    

}

 

// 处理发送完的响应结果

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

{

    [self dismissModalViewControllerAnimated:YES];

    

    if (result == MessageComposeResultCancelled)

        NSLog(@"Message cancelled");

        else if (result == MessageComposeResultSent)

            NSLog(@"Message sent");

            else 

                NSLog(@"Message failed")  ;

               

//                }

}

iOS 调用带内容的短信页面