iOS 一键加入QQ群

获取加群组件的网址:http://qun.qq.com/join.html


然后通过它获取到的代码:

- (BOOL)joinGroup:(NSString *)groupUin key:(NSString *)key

{

    NSString *urlStr = [NSStringstringWithFormat:@"mqqapi://card/show_pslcard?src_type=internal&version=1&uin=%@&key=%@&card_type=group&source=external",@"48423578396",@"959d333984b2deb937df28c4af43e3df678f8ec616a43e91c828e7ee563c4163"];

    NSURL *url = [NSURLURLWithString:urlStr];

    if([[UIApplicationsharedApplication] canOpenURL:url]){

        [[UIApplicationsharedApplication] openURL:url];

        returnYES;

    }

    elsereturn NO;

}


因为需要点击事件触发所以修改为如下代码

#pragma mark - 加群

-(void)qqButtonAction:(UIButton *)button

{

    NSString *urlStr = [NSStringstringWithFormat:@"mqqapi://card/show_pslcard?src_type=internal&version=1&uin=%@&key=%@&card_type=group&source=external",@"484558396",@"959d333984b2deb937df28c4af43e3df678f8ec616a43e91c828e7ee563c4163"];

    NSURL *url = [NSURLURLWithString:urlStr];

    if([[UIApplicationsharedApplication] canOpenURL:url]){

        

        [[UIApplicationsharedApplication] openURL:url];

        

    }

}

你可能感兴趣的:(iOS)