记一个比较简单的问题.最近产品一个需求是需要在在iOS上打开qq群,qq官网https://qun.qq.com/join.html
这边给了现成的OC代码,
- (BOOL)joinGroup:(NSString *)groupUin key:(NSString *)key{
NSString *urlStr = [NSString stringWithFormat:@"mqqapi://card/show_pslcard?src_type=internal&version=1&uin=%@&key=%@&card_type=group&source=external", @"25067XXXX",@"c6e2a8027c9970ba3c4785c919c989956530270e8fa7e93b87dXXXXXXXXX"];
NSURL *url = [NSURL URLWithString:urlStr];
if([[UIApplication sharedApplication] canOpenURL:url]){
[[UIApplication sharedApplication] openURL:url];
return YES;
}
else return NO;
}
但是在iOS10后出了这个方法
UIApplication.shared.open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any] = [:], completionHandler completion: ((Bool) -> Void)? = nil)
如果需要填写options参数的话可以填[UIApplication.OpenExternalURLOptionsKey.universalLinksOnly:false] 这样就能正常打开qq了.当然还是要在info.plist文件中添加
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mqqapi</string>
</array>
网友评论