一、跳到指定的群的页面:申请加群页面(当前用户不是群成员)、发消息页面(已经是群成员的情况)
- (NSURL*)getQQQunUrl {
NSString *qq_number = @"??"
NSString* urlStr = [NSString stringWithFormat:@"mqqapi://card/show_pslcard?src_type=internal&version=1&uin=%@&key=%@&card_type=group&source=external", qq_number, @"44a6e01f2dab126f87ecd2ec7b7e66ae259b30535fd0c2c25776271e8c0ac08f"];
return [NSURL URLWithString:urlStr];
}
NSURL* url = [self getQQqunUrl];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
二、跳转到客服QQ发起临时会话
//qqNumber就是你要打开的QQ号码, 也就是你的客服号码。
NSString *qqNumber=@"QQ号";
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]]) {
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSURL * url=[NSURL URLWithString:[NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqNumber]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
webView.delegate = self;
[webView loadRequest:request];
[self.view addSubview:webView];
}
参考:
网友评论