两个app之间的跳转 判断一个app是否存在

来源:互联网 发布:淘宝一键复制赚佣金 编辑:程序博客网 时间:2024/05/21 16:56
{
//测试
UIButton * tenBtn = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 30)];
tenBtn.backgroundColor = [UIColor redColor];
[bgImageView addSubview:tenBtn];
tenBtn.enabled = YES;
[tenBtn addTarget:self action:@selector(taoBtn:) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark -- 测试 两个app之间的跳转
- (void)taoBtn:(UIButton *)tr{
//判断本地是否有淘宝App
NSURL * myURL_APP_A = [NSURL URLWithString:@"taobao://"];
if ([[UIApplication sharedApplication] canOpenURL:myURL_APP_A]) {
NSLog(@"canOpenURL");
[[UIApplication sharedApplication] openURL:myURL_APP_A];
}
else{
NSLog(@"淘宝图标不显示");
//没有 就直接跳转到app store 进行手动下载
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8"]];
}

}

//找到应用描述的连接比如:http://itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8
然后将 http:// 替换为 itms:// 或者 itms-apps://:就可以了
同事也要设置白名单
0 0
原创粉丝点击