在iOS应用中跳转到淘宝或天猫客户端商品详情页

论坛 期权论坛 脚本     
匿名技术用户   2020-12-22 10:36   53   0

最近做iOS项目的时候遇到一个需求,启动图片后是广告页,点击广告页,跳转到淘宝或天猫的商品详情页。

具体需要是这样:

1)安装了淘宝:跳转到淘宝详情页。

2)没装淘宝,装了天猫:跳转到天猫详情页

3)淘宝、天猫都没装:跳转到应用自己的页面,加载网页。


1)可以使用阿里百川的SDK完成。 文档地址:http://baichuan.taobao.com/doc2/detail.htm?spm=a3c0d.7629140.0.0.fXnfzs&treeId=51&articleId=102860&docType=1

2)拿到淘宝、天猫url scheme及相应的链接,自己完成跳转。代码如下:

NSURL *taobaoUrl = [NSURL URLWithString:[NSString stringWithFormat:@"taobao://item.taobao.com/item.htm?id=%@", book_id]];

NSURL *tmallUrl = [NSURL URLWithString:[[NSString stringWithFormat:@"tmall://tmallclient/?{\"action\":\"item:id=%@\"}", book_id] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

if ([[UIApplication sharedApplication] canOpenURL:taobaoUrl]) {

//能打开淘宝就打开淘宝

[[UIApplication sharedApplication] openURL:taobaoUrl];

} else if ([[UIApplication sharedApplication] canOpenURL:tmallUrl]) {

//能打开天猫就打开天猫

[[UIApplication sharedApplication] openURL:tmallUrl];

} else {

//都打不开就自己加载网页

KGAdWebVC *adWebVC = [[KGAdWebVC alloc] init];

adWebVC.url = splash_url;

[self.navigationController pushViewController:adWebVC animated:YES];

}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP