zoukankan      html  css  js  c++  java
  • 每日分享 - 发送短信/邮件/打电话

    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]];
        
    }
  • 相关阅读:
    Badboy参数化
    Badboy运行脚本
    Badboy中创建Suite, test, step和Template
    美食
    Badboy录制模式
    美食
    BadBoy+JMeter来录制和运行Web测试脚本
    JMeter简介及使用JMeter来访问网站
    软件测试的艺术
    泗泾办小卡需要的材料
  • 原文地址:https://www.cnblogs.com/xingchen/p/2271403.html
Copyright © 2011-2022 走看看