IOS APP中打开指定qq聊天界面

作者: 红姑娘 | 来源:发表于2016-10-18 09:38 被阅读5709次

在浏览器中可以通过JS代码打开QQ并弹出聊天界面,一般作为客服QQ使用。而在移动端腾讯没有公布提供类似API,但是却可以使用schema模式来启动手机QQ

  //qqNumber就是你要打开的QQ号码, 也就是你的客服号码。
   NSString  *qqNumber=@"1918263902";

    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];
}else{
    
      UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"nil" message:@"对不起,您还没安装QQ" preferredStyle:UIAlertControllerStyleAlert];
    
      UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        
          [tableView deselectRowAtIndexPath:indexPath animated:NO];
          return ;
    }];
    
      [alertController addAction:cancelAction];
      [self presentViewController:alertController animated:YES completion:nil];

注意:如果你的QQ不是客服QQ会出现红色的感叹号如下:

26C7C0E524D8E1DBF81764A4C856A324.png

想要解决也很简单打开QQ推广设置一下就可以了
1.打开http://shang.qq.com/v3/index.html 点击推广工具------> 点击立即免费开通

屏幕快照 2016-10-18 09.55.33.png

2.点击QQ通讯组件------>选择标准型组件样式 点击设置

屏幕快照 2016-10-18 09.49.47.png

3.设置自动回复 和 会话能力


屏幕快照 2016-10-18 10.05.39.png

4.向下滚动设置权限和安全级别

屏幕快照 2016-10-18 10.05.50.png

设置完之后大家再试一下 是不是就可以正常聊天了那

相关文章

网友评论

  • WLZero:iOS 10以后
    //在这里放QQ号
    NSString *qqNumber = @"2158015525";
    NSString *openQQUrl = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqNumber];
    NSURL *url = [NSURL URLWithString:openQQUrl];
    [[UIApplication sharedApplication] openURL:url];
  • 7ac161573ae3:为什么我的点击以后 就显示 没安装QQ
    銀河煋爆:可能是没有安装, 或者是 plist 里面没有添加 mqq 的白名单
  • 新地球说着一口陌生腔调:打开企业qq如何设置
  • 阿凡提说AI:不管用呀,ios10
    銀河煋爆:plist 里面还有添加 mqq 的白名单
    WLZero:iOS 10以后
    //在这里放QQ号
    NSString *qqNumber = @"2158015525";
    NSString *openQQUrl = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqNumber];
    NSURL *url = [NSURL URLWithString:openQQUrl];
    [[UIApplication sharedApplication] openURL:url];
  • 投降又不会赢:您好 如果是在iOS移动端内 跳转到非好友聊天界面该怎么做呢? 谢谢
    投降又不会赢:@kmonarch 只是跳转以前提示的 需要加为好友。 并没有实际解决问题。
    Charles_Zhang:您好,请问您解决了这个问题没有啊?
  • 万少:为啥我的没反应啊
    銀河煋爆:plist 里面还有添加 mqq 的白名单
    WLZero:iOS 10以后
    //在这里放QQ号
    NSString *qqNumber = @"2158015525";
    NSString *openQQUrl = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqNumber];
    NSURL *url = [NSURL URLWithString:openQQUrl];
    [[UIApplication sharedApplication] openURL:url];
    阿凡提说AI:我的也没反应,咋弄呀
  • 因猿际会:打开的不是指定的qq聊天界面 而是群聊天界面的话 怎么设置呢
  • zero000:您好,我想问下:通过项目客户端打开qq如何自动发送某个消息(消息实时更新)给指定的人呢?

本文标题:IOS APP中打开指定qq聊天界面

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