iOS开发之发送短信

2018-07-20    来源:open-open

容器云强势上线!快速搭建集群,上万Linux镜像随意使用
    //  调用系统API发送短信  
    - (void)didClickSendMessageButtonAction{  
          
        if ([MFMessageComposeViewController canSendText] == YES) {  
              
            MFMessageComposeViewController *messageVC = [[MFMessageComposeViewController alloc] init];  
            //  设置代理<MFMessageComposeViewControllerDelegate>  
            messageVC.messageComposeDelegate = self;  
            //  发送To Who  
            messageVC.recipients = @[@"18757289870"];  
            messageVC.body = @"hello world";  
            [self presentViewController:messageVC animated:YES completion:nil];  
              
        }else{  
          
            NSLog(@"此设备不支持");  
        }  
    }  
      
    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{  
          
        switch (result) {  
            case MessageComposeResultCancelled:  
                NSLog(@"取消发送");  
                break;  
            case MessageComposeResultFailed:  
                NSLog(@"发送失败");  
                break;  
            case MessageComposeResultSent:  
                NSLog(@"发送成功");  
                break;  
            default:  
                break;  
        }  
          
        [self dismissViewControllerAnimated:YES completion:nil];  
      
    }  
      
    //  调用系统应用程序发送消息  
    - (void)didClickSendMessage2ButtonAction{  
          
        NSURL *url = [NSURL URLWithString:@"sms:18656348970"];  
        if ([[UIApplication sharedApplication] canOpenURL:url] == YES) {  
              
            [[UIApplication sharedApplication] openURL:url];  
              
        }else{  
          
            NSLog(@"失败");  
        }  
      
    }  

标签: idc

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。

上一篇: Android设备唯一标识ID的获取

下一篇:iOS打开相机的闪光灯