zoukankan      html  css  js  c++  java
  • IOS 掉用系统发短信

    
    

    #import <MessageUI/MessageUI.h>

    MFMessageComposeViewControllerDelegate

    #pragma mark - 调用ios系统短信发送模块
    -(void)shareUseSMSWithMessage:(NSString *)message
    {
        Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
        if (messageClass != nil) {
            // Check whether the current device is configured for sending SMS messages
            if ([messageClass canSendText]) {
                MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
                picker.messageComposeDelegate = self;
                picker.body = message;
                [self.navigationController presentViewController:picker animated:YES completion:nil];
            }
            else {
                UIAlertView *canSend = [[UIAlertView alloc] initWithTitle:@"设备没有短信功能" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"关闭", nil];
                [canSend show];
            }
        }else{
            UIAlertView *visionAlert = [[UIAlertView alloc] initWithTitle:@"iOS版本过低,iOS4.0以上才支持程序内发送短信" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"关闭", nil];
            [visionAlert show];
        }
    }
    
    #pragma mark - MFMessageComposeViewControllerDelegate
    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
    {
        switch (result)
        {
            case MessageComposeResultCancelled:
                NSLog(@"Result: SMS sending canceled");
                break;
            case MessageComposeResultSent:
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"短信发送成功" delegate:nil cancelButtonTitle:@"关闭" otherButtonTitles:nil];
                [alert show];
                NSLog(@"Result: SMS sent");
            }
                break;
            case MessageComposeResultFailed:
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"短信发送失败" delegate:nil cancelButtonTitle:@"关闭" otherButtonTitles:nil];
                [alert show];
            }
                break;
            default:
                NSLog(@"Result: SMS not sent");
                break;
        }
        [self dismissViewControllerAnimated:YES completion:nil];
    }
  • 相关阅读:
    unity UGUI实现类似NGUI切换Sprite的方式
    商业智能系统在税务行业的应用
    MSRDS机器人仿真软件学习资源汇总
    Emotiv脑电设备与RDS机器人仿真初步测试
    unity使用UGUI创建摇杆
    如何利用FineBI做财务分析
    Android4.2.2源码目录结构分析
    一个前端妹子的悲欢编程之路
    推荐一款优雅高效的免费在线APP原型工具
    数据分析概述和理论基础
  • 原文地址:https://www.cnblogs.com/joesen/p/3633834.html
Copyright © 2011-2022 走看看