iOS 打电话、唤起微信、QQ

作者: 流沙3333 | 来源:发表于2017-02-22 17:16 被阅读495次

//跳转到qq聊天界面

+ (void)callQQ:(NSString*)qq {

if([selfisQQInstalled]) {

NSString* qqUrl = [NSStringstringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qq];

UIWebView* webview = [[UIWebViewalloc]initWithFrame:CGRectZero];

[[UIApplicationsharedApplication].keyWindowaddSubview:webview];

NSURL*url = [NSURLURLWithString:qqUrl];

NSURLRequest*request = [NSURLRequestrequestWithURL:url];

[webviewloadRequest:request];

}

}

+ (BOOL)isQQInstalled{

NSString*urlStr = [NSStringstringWithFormat:@"mqqapi://card/show_pslcard?src_type=internal&version=1&uin=6481427ed9be2a6b6df78d95f2abf8a0ebaed07baefe3a2bea8bd847cb9d84ed&card_type=group&source=external"];

NSURL*url = [NSURLURLWithString:urlStr];

if([[UIApplicationsharedApplication]canOpenURL:url]){

returnYES;

}

else{

[YBAlertViewalertWithTile:@"提示"message:@"尚未安装QQ,请安装QQ后重试"delegate:nilbtn1:@"确定"btn2:nil];

returnNO;

}

}

//跳转到微信

+ (void)callWeChat:(NSString*)Weixin {

if([selfisWeChatInstalled]) {

NSString* qqUrl = [NSStringstringWithFormat:@"weixin://"];

UIWebView* webview = [[UIWebViewalloc]initWithFrame:CGRectZero];

[[UIApplicationsharedApplication].keyWindowaddSubview:webview];

NSURL*url = [NSURLURLWithString:qqUrl];

NSURLRequest*request = [NSURLRequestrequestWithURL:url];

[webviewloadRequest:request];

}

}

+ (BOOL)isWeChatInstalled{

NSString*urlStr = [NSStringstringWithFormat:@"weixin://"];

NSURL*url = [NSURLURLWithString:urlStr];

if([[UIApplicationsharedApplication]canOpenURL:url]){

NSLog(@"已安装微信了");

returnYES;

}

else{

[YBAlertViewalertWithTile:@"提示"message:@"尚未安装微信,请安装微信后重试"delegate:nilbtn1:@"确定"btn2:nil];

returnNO;

}

}

//打电话

+ (void)callPhone:(NSString*)phone {

NSMutableString* str=[[NSMutableStringalloc]initWithFormat:@"tel:%@",phone];

UIWebView* callWebview = [[UIWebViewalloc]init];

[callWebviewloadRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:str]]];

[[UIApplicationsharedApplication].keyWindowaddSubview:callWebview];

}

相关文章

网友评论

    本文标题:iOS 打电话、唤起微信、QQ

    本文链接:https://www.haomeiwen.com/subject/wsumwttx.html