美文网首页技术
如何调用系统发送信息?

如何调用系统发送信息?

作者: 952625a28d0d | 来源:发表于2015-11-16 12:17 被阅读26次
    • 第一种方法
      使用MFMessageComposeViewController系统的邮箱系统来发送信息

    添加库:

    Paste_Image.png

    引入头文件:

    Paste_Image.png

    代码:

    #import "ViewController.h"
    #import <MessageUI/MessageUI.h>
    
    // 遵守代理
    @interface ViewController ()<MFMailComposeViewControllerDelegate,MFMessageComposeViewControllerDelegate>
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    
        // 启动信息模块
        if ([MFMessageComposeViewController canSendText]) {
            MFMessageComposeViewController *messageComposer =
            [[MFMessageComposeViewController alloc] init];
            NSString *message = @"Message!!!";
            [messageComposer setBody:message];
            messageComposer.messageComposeDelegate = self;
            [self presentViewController:messageComposer animated:YES completion:nil];
        }
    }
    
    // 处理发送结果
    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
        
        ///your stuff here
        
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end```
    
    - 第二种方法
    
    

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

    相关文章

      网友评论

        本文标题:如何调用系统发送信息?

        本文链接:https://www.haomeiwen.com/subject/gfvkhttx.html