iOS开发之调起QQ客户端

2016-11-25  本文已影响24人  向晚forever

需要注意的是,iOS9以上的系统需要在info.plist添加白名单

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>wechat</string>
        <string>weixin</string>
        <string>alipay</string>
        <string>alipayshare</string>
        <string>mqq</string>
    </array>
    if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]])
    {
        NSString *QQ = @"1099779883";
        //调用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]];
    }
    else{
        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"手机未安装QQ" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
    }
上一篇 下一篇

猜你喜欢

热点阅读