码迷,mamicode.com
首页 > 移动开发 > 详细

判断APP是否已安装

时间:2018-07-27 20:55:33      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:key   option   lse   安装   link   sch   open   install   aci   

    NSString *str = [NSString stringWithFormat:@"%@://%@",[dic objectForKey:@"ios_url_scheme"],[dic objectForKey:@"app_bundle_id"]];
    NSURL *app_url = [NSURL URLWithString:str];
    BOOL hasInstalled = [[UIApplication sharedApplication] canOpenURL:app_url];
    if (hasInstalled){
        //说明此设备有安装app,打开APP
        if (APP_Version.doubleValue <= 10) {
            [[UIApplication sharedApplication] openURL:app_url];
        }else{
            [[UIApplication sharedApplication] openURL:app_url options:@{} completionHandler:nil];
        }
    }else{
        //说明此设备没有安装app,跳转APP_STORE
        NSString *link = [dic objectForKey:@"app_link_ios"];
        if (link.length != 0) {
            NSString *link_pro = [link stringByReplacingOccurrencesOfString:@"https" withString:@"itms-apps"];
            if (APP_Version.doubleValue <= 10) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:link_pro]];
            }else{
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:link_pro] options:@{} completionHandler:nil];
            }
        }
    }

 

判断APP是否已安装

标签:key   option   lse   安装   link   sch   open   install   aci   

原文地址:https://www.cnblogs.com/wycstudy/p/9379189.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!