对于系统iOS 9之后,把需要检测的UrlScheme添加到白名单即可,添加方法:info.plist 增加LSApplicationQueriesSchemes (array类型),把要检测的app的UrlScheme加进去。
- 手淘的白名单 :tbopen
- 京东 : openapp.jdmobile
- 拼多多 :pinduoduo
- 抖音电商 :snssdk1128
跳转到各电商平台商品详情页
//手淘是通过阿里百川跳转的
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tbopen://"]]) {
//拉起手淘
AlibcTradeShowParams *showParams = [[AlibcTradeShowParams alloc] init];
showParams.openType = AlibcOpenTypeAuto;
showParams.backUrl = @"tbopen33234200://";
showParams.isNeedPush = YES;
[[AlibcTradeSDK sharedInstance].tradeService openByUrl:jumpUrl identity:@"trade" webView:[WKWebView new] parentController:RootNavController showParams:nil taoKeParams:nil trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
} tradeProcessFailedCallback:^(NSError * _Nullable error) {
}];
}
NSString *canOpenUrl = @"pinduoduo://";//拼多多
NSString *canOpenUrl = @"openapp.jdmobile://";//京东
NSString *canOpenUrl = @"snssdk1128://";//抖音
//webUrlString为后台返回的详情页链接
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:canOpenUrl]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:webUrlString] options:[NSDictionary dictionary] completionHandler:^(BOOL success) {
}];
}