zoukankan      html  css  js  c++  java
  • 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来进行跳转,相对简单,但是有拒绝风险

  • 相关阅读:
    centos7 做rails 执行rails server 报错
    centos 7 安装 rvm 超时
    centos7 打造基于python语言Selenium2自动化开发环境
    RubyMine8 安装
    linux 下安装 RZ SZ命令 以及使用
    centos 7.2 安装mysql 修改 初始密码
    win10系统配置FTP
    Windows环境安装MySQL8.0.11
    IntelliJ IDEA 2017 上传本地项目至码云
    IntelliJ IDEA 2017.3 搭建一个多模块的springboot项目(三)
  • 原文地址:https://www.cnblogs.com/lidarui/p/9083012.html
Copyright © 2011-2022 走看看