關(guān)于APP內(nèi)跳轉(zhuǎn)到QQ界面和直接撥打電話

我們在開發(fā)APP 的過程中會經(jīng)常遇到這樣的需求,跳轉(zhuǎn)到客服QQ界面,撥打電話等,直接上代碼

1.關(guān)于APP跳轉(zhuǎn)到客服QQ界面

 // 空白的webview
   UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectZero];
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]]) {
    
    //1691838426 是QQ號
    
    NSString * string = @"mqq://im/chat?chat_type=wpa&uin=1691838426&version=1&src_type=web";
    
    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"shipping要打開你的QQ" message:nil preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *callAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
    }];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }];
    
    [actionSheet addAction:cancelAction];
    [actionSheet addAction:callAction];
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:actionSheet animated:YES completion:nil];
    [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:webView];
    
}else{
    
    UIAlertView*ale=[[UIAlertView alloc] initWithTitle:@"提示" message:@"您沒有安裝手機(jī)QQ,請安裝手機(jī)QQ后重試,或用PC進(jìn)行操作。" delegate:self cancelButtonTitle:nil otherButtonTitles:@"確定", nil];
    [ale show];
    
}

2.關(guān)于APP直接撥打電話又三種實現(xiàn)方式

  • 第一種:直接撥打電話,沒有提示
    //撥打電話
    UIApplication *ac = [UIApplication sharedApplication];

      NSURL *url = [NSURL URLWithString:[@"tel://"   stringByAppendingString:@"你要放的電話號碼"]];
    
      [ac openURL:url];
    
  • 第二種:打完電話后還會回到原來的程序,也會彈出提示,
    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"你要放的電話號碼"];
    UIWebView * callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    [self.view addSubview:callWebview];

  • 第三種: 打完電話后還會回到原來的程序,也會彈出提示,
    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",@"你要放的電話號碼"];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容