iOS 三種撥打電話

沒辦法看到有人提這個問題,然後就來此分享一下,裝裝逼...


//TKCTelephoningTypeApplicationTelprompt與TKCTelephoningTypeApplicationTelprompt幾乎效果一樣,只多了一層黑色非常透明的絲襪
typedef enum : NSUInteger {
    TKCTelephoningTypeApplicationWebView = 0,//在手機電話APP撥打,先在本APP內彈窗提示,需確認撥打。
    TKCTelephoningTypeApplication,//在手機電話APP直接撥打,無提示。結束通話後返回當前APP界面
    TKCTelephoningTypeApplicationTelprompt,//在手機電話APP撥打,先在本APP內彈窗提示,需確認撥打。聽說此方法上架APP容易被拒??
} TKCTelephoningType;


/**
 撥打電話

 @param phoneNum        電話號碼
 @param telephoningType 撥打類型 見TKCTelephoningType
 */
+ (void)userTelephoningNum:(NSString *)phoneNum type:(TKCTelephoningType)telephoningType{

    switch (telephoningType) {
        case TKCTelephoningTypeApplicationWebView:
        {
            phoneNum = [@"tel:" stringByAppendingString:phoneNum];
            //
            UIWebView *webView = [[UIWebView alloc] init];
            [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:phoneNum]]];
            [[UIApplication sharedApplication].keyWindow addSubview:webView];
        }
            break;
        case TKCTelephoningTypeApplication:
        {
            phoneNum = [@"tel:" stringByAppendingString:phoneNum];
            //
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNum]];
        }
            break;
        case TKCTelephoningTypeApplicationTelprompt:
        {
            phoneNum = [@"telprompt://" stringByAppendingString:phoneNum];
            //
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNum]];
        }
            break;
            
        default:
            break;
    }

}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章