zoukankan      html  css  js  c++  java
  • 发送短信/邮件/打电话的代码

    + (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]];
       
    }

    也可以下载第三方  按照SDK操作

  • 相关阅读:
    标志寄存器和跳转指令
    js中top、clientTop、scrollTop、offsetTop的区别 文字详细说明版【转】
    关于mysql的级联删除(之前好多人咨询过我)
    用DIV画个漂亮的Table,根本看不出是div画的
    最简单的Ajax局部提交整体form,无刷新页面
    themeleaf中使用javascript时,字符“&&”的转义问题。
    Mysql 进行sequence的新建,同时建立计划每日重置。
    动态给H5页面绑定数据,基本万能无错误!
    手风琴效果简单实现,修改bootstrap内部事件接口并且自由定义。
    JQuery实现追加表格,不使用拼接html方式
  • 原文地址:https://www.cnblogs.com/jinlianglu/p/6399533.html
Copyright © 2011-2022 走看看