• 每日分享 - 发送短信/邮件/打电话


    Link Address:http://www.cocoachina.com/bbs/read.php?tid=20993&fpage=3

    每日分享 - 发送短信/邮件/打电话   

     
     
    很简单的方法了

    + (void)alert:(NSString *)msg
    {
        UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:msg message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease];
        [alertView showWithBackground];
    }

    + (NSString*) cleanPhoneNumber:(NSString*)phoneNumber
    {
        NSString* number = [NSString stringWithString:phoneNumber];
        NSString* number1 = [[[number stringByReplacingOccurrencesOfString:@" " withString:@""]
                              //                        stringByReplacingOccurrencesOfString:@"-" withString:@""]
                              stringByReplacingOccurrencesOfString:@"(" withString:@""] 
                             stringByReplacingOccurrencesOfString:@")" withString:@""];
        
        return number1;    
    }

    + (void) makeCall:(NSString *)phoneNumber
    {
        if ([DeviceDetection isIPodTouch]){
            [UIUtils alert:kCallNotSupportOnIPod];
            return;
        }
        
        NSString* numberAfterClear = [UIUtils cleanPhoneNumber:phoneNumber];    
        
        NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", numberAfterClear]];
        NSLog(@"make call, URL=%@", phoneNumberURL);
        
        [[UIApplication sharedApplication] openURL:phoneNumberURL];    
    }

    + (void) sendSms:(NSString *)phoneNumber
    {
        if ([DeviceDetection isIPodTouch]){
            [UIUtils alert:kSmsNotSupportOnIPod];
            return;
        }
        
        NSString* numberAfterClear = [UIUtils cleanPhoneNumber:phoneNumber];
        
        NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"sms:%@", numberAfterClear]];
        NSLog(@"send sms, URL=%@", phoneNumberURL);
        [[UIApplication sharedApplication] openURL:phoneNumberURL];    
    }

    + (void) sendEmail:(NSString *)phoneNumber
    {
        NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@", phoneNumber]];
        NSLog(@"send sms, URL=%@", phoneNumberURL);
        [[UIApplication sharedApplication] openURL:phoneNumberURL];    
    }

    + (void) sendEmail:(NSString *)to cc:(NSString*)cc subject:(NSString*)subject body:(NSString*)body
    {
        NSString* str = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@",
                         to, cc, subject, body];

        str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
        
    }
  • 相关阅读:
    安装archlinux的另辟蹊径的命令及心得
    deepin15.11安装N卡驱动,实测!!!(可解决N卡电脑关机卡屏)
    js实现简单下载
    微信公众号的开发 该公众号提供的服务出现故障,请稍后再试
    线程池的创建
    多线程,生产者消费者模型(生产馒头,消费馒头)
    第1章 Java IO系统 下
    T01章[Java IO系统] 作业
    第1章 Java IO系统
    用集合实现一个控制台版的学生管理系统
  • 原文地址:https://www.cnblogs.com/xingchen/p/2271403.html
Copyright © 2020-2023  润新知