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"]?@"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"]?@"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"]?@"QQ":([urlStr hasPrefix:@"weixin"]?@"微信":@"支付宝");
                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来进行跳转,相对简单,但是有拒绝风险

原文地址:https://www.cnblogs.com/lidarui/p/9083012.html