关于app安全性

iOS 应用内跳转商城

2021-05-21  本文已影响0人  Gordon_gc

app有销售推广公司产品的需求(但不是主要功能,比如app是对公司的一款硬件所配套的软件,所以app主要的任务是更好的控制硬件,与硬件进行交互,但在app中我们还想推广其他产品),如果单独做这个功能费时费力(需要详情展示、支付、地址管理等等等),还有一种方案就是只做一个商品列表页面,点击直接跳转到对应的京东、淘宝等店铺或商品详情页面。

跳到京东

- (void)jshopMain:(NSString *)productID
{
    NSString *urlStr = [NSString stringWithFormat:@"openApp.jdMobile://virtual?params={\"category\":\"jump\",\"des\":\"jshopMain\",\"shopId\":\"%@\",\"sourceType\":\"homefloor\",\"sourceValue\":\"4384\",\"landPageId\":\"jshop.cx.mobile\"}", productID];
    NSURL *newUrl = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    [[UIApplication sharedApplication] openURL:newUrl options:@{} completionHandler:nil];
    if ([[UIApplication sharedApplication] canOpenURL:newUrl]) {
        [[UIApplication sharedApplication] openURL:newUrl options:@{} completionHandler:nil];
    }else{
        //直接跳转html
    }
}

跳转商品主页

- (void)skuId:(NSString *)productID
{
    NSString *urlStr = [NSString stringWithFormat:@"openApp.jdMobile://virtual?params={\"category\":\"jump\",\"des\":\"productDetail\",\"skuId\":\"%@\",\"sourceType\":\"homefloor\",\"sourceValue\":\"4384\",\"landPageId\":\"jshop.cx.mobile\"}", productID];
    NSURL *newUrl = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    if ([[UIApplication sharedApplication] canOpenURL:newUrl]) {
        [[UIApplication sharedApplication] openURL:newUrl options:@{} completionHandler:nil];
    }else{
        //直接跳转html
    }
}
上一篇下一篇

猜你喜欢

热点阅读