你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iphone應用開發之十:發送短信/郵件/打電話

iphone應用開發之十:發送短信/郵件/打電話

編輯:IOS開發綜合

 

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

       

}     

 


作者 andy-清風
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved