iOS 10跳转到其他app
Posted timeToShow
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS 10跳转到其他app相关的知识,希望对你有一定的参考价值。
- (BOOL)jumpsToThirdAPP:(NSString *)urlStr{ if ([urlStr hasPrefix:@"mqq"] || [urlStr hasPrefix:@"weixin"] || [urlStr hasPrefix:@"alipay"]) { if (@available(ios 10.0, *)) { [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlStr] options:@{} completionHandler:nil]; return YES; } else { BOOL success = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:urlStr]] ; if (success) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]]; }else{ NSString *appurl = [urlStr hasPrefix:@"alipay"][email protected]"https://itunes.apple.com/cn/app/%E6%94%AF%E4%BB%98%E5%AE%9D-%E8%AE%A9%E7%94%9F%E6%B4%BB%E6%9B%B4%E7%AE%80%E5%8D%95/id333206289?mt=8":([urlStr hasPrefix:@"weixin"][email protected]"https://itunes.apple.com/cn/app/%E5%BE%AE%E4%BF%A1/id414478124?mt=8":@"https://itunes.apple.com/cn/app/qq/id444934666?mt=8"); NSString *title = [urlStr hasPrefix:@"mqq"][email protected]"QQ":([urlStr hasPrefix:@"weixin"][email protected]"微信":@"支付宝"); NSString *titleString = [NSString stringWithFormat:@"该设备未安装%@客户端",title]; UIAlertController *controller = [UIAlertController alertControllerWithTitle:nil message:titleString preferredStyle:UIAlertControllerStyleAlert]; [controller addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]]; [controller addAction:[UIAlertAction actionWithTitle:@"立即安装" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSURL *url = [NSURL URLWithString:appurl]; [[UIApplication sharedApplication] openURL:url]; }]]; [self presentViewController:controller animated:YES completion:nil]; } return YES; } } return NO; }
或者使用url scheme来进行跳转,相对简单,但是有拒绝风险
以上是关于iOS 10跳转到其他app的主要内容,如果未能解决你的问题,请参考以下文章