以前没注意到,打开第三方app有个坑,现在有个需求是跳转到微信去,一开始傻乎乎的在url schemes 里面添加微信
WechatIMG47.jpeg
这样添加是做支付和分享的时候添加的白名单,如果这样添加iOS10以后的手机是没问题的,但是iOS 10以前的手机就打不开微信,正确的添加方式是这样的
image.png
然后代码如下
// 联系客服
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"请关注微信公众号\nmmmmm" message:@"与客服进行沟通" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"知道了"style:UIAlertActionStyleDestructive handler:nil];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"去微信" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *url = [NSURL URLWithString:@"weixin://"];
if ([APPLICATION canOpenURL:url]) {
[APPLICATION openURL:url];
}else{
[UIAlertView showWithTitle:@"警告" message:@"您还未安装微信" cancelButtonTitle:@"知道了"];
}
}];
[alertController addAction:cancel];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:^{
}];
效果如下
image.png
如果用户未安装微信,给个提示
image.png