iOS 开启QQ临时会话

450 阅读1分钟

0

打开QQ推广网址 http://shang.qq.com 并用接收临时消息QQ号登录

1

在项目info.plist添加LSApplicationQueriesSchemes字段 类型Array 在此Array中添加一个 item 值设为:mqq

2

//是否安装QQ
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]]) {
  //用来接收临时消息的客服QQ号码(注意此QQ号需开通QQ推广功能,否则陌生人向他发送消息会失败)
  NSString *QQ = @"xxxxx";
  //调用QQ客户端,发起QQ临时会话
  NSString *url = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",QQ];              
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}