iOS 打开QQ并创建临时会话(不用接入第三方SDK。如正常接收消息要开通QQ推广)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/saw471/article/details/86539249
/**
 调起 QQ客户端
 1. Info.plist 中添加 LSApplicationQueriesSchemes 类型Array。
 2. 在 LSApplicationQueriesSchemes 中添加 item 值为 mqq
 
 @param QQ 用来接收消息的QQ号码 并开通QQ推广功能,否则陌生人向他发送消息会失败
 */
-(void)openQQ:(NSInteger)QQ
{
    // 检测QQ 客户端是否安装
    if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]])
    {
        //调用QQ客户端,发起QQ临时会话
        NSString *qqStr = [NSString stringWithFormat:@"%zd",QQ];
        NSString *url = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqStr];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
    }
    
}

QQ 推广开通地址 http://shang.qq.com/v3/index.html

猜你喜欢

转载自blog.csdn.net/saw471/article/details/86539249