好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Html5跳轉到APP指定頁面的實現

Html5跳轉到APP指定頁面的實現

熱門標簽:電話機器人技術 黃石ai電銷機器人呼叫中心 智能電銷機器人被禁用了么 高德地圖標注商戶怎么標 ok電銷機器人 地圖標注軟件打印出來 惡搞電話機器人 如何查看地圖標注 欣鼎電銷機器人 效果

1.設置urlschemes

urlschemes盡量設一個唯一的字符串,例如可以設為:iOS+公司英文名+ 項目工程名
比如我的設為iOSTencentTest,在瀏覽器中輸入地址iOSTencentTest://即可跳轉到我的app

2.跳轉到指定頁面

在使用iOSTencentTest://打開app會調用AppDelegate的代理方法

-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options

跳轉指定頁面在該方法中操作
iOSTencentTest://后面是可以添加參數的,例如iOSTencentTest://goodsDetails?id=xxxxx
goodsDetails可直接通過url.host獲取
id=xxxxx 參數可直接通過url.query獲取
可以根據自身需求去設置不同的host和參數。

h5那邊只需要執行:

window.location.href = 'iOSTencentTest://goodsDetails?id=xxxxx'

附:

//獲取Window當前顯示的ViewController
- (UIViewController*)currentViewController{
    //獲得當前活動窗口的根視圖
    UIViewController* vc = [UIApplication sharedApplication].keyWindow.rootViewController;
    while (1)
    {
        //根據不同的頁面切換方式,逐步取得最上層的viewController
        if ([vc isKindOfClass:[UITabBarController class]]) {
            vc = ((UITabBarController*)vc).selectedViewController;
        }
        if ([vc isKindOfClass:[UINavigationController class]]) {
            vc = ((UINavigationController*)vc).visibleViewController;
        }
        if (vc.presentedViewController) {
            vc = vc.presentedViewController;
        }else{
            break;
        }
    }
    return vc;
}
//NSString類別方法
//通過url.query獲取參數字符 再分成字典 
-(NSMutableDictionary *)getURLParameters
{
    if (!self.length) {
        return nil;
    }
    NSMutableDictionary  *params = [NSMutableDictionary   dictionary];
    if ([self containsString:@"&"]) {
        NSArray *urlComponents = [self componentsSeparatedByString:@"&"];

        for(NSString *keyValuePair in urlComponents) {

            //生成key/value
            NSArray *pairComponents = [keyValuePair componentsSeparatedByString:@"="];
            NSString *key = [pairComponents.firstObject stringByRemovingPercentEncoding];
            NSString*value = [pairComponents.lastObject stringByRemovingPercentEncoding];

            //key不能為nil

            if(key==nil|| value ==nil) continue;

            id existValue = [params valueForKey:key];
            if(existValue !=nil) {
                //已存在的值,生成數組。
                if([existValue isKindOfClass:[NSArray class]]) {
                    //已存在的值生成數組
                    NSMutableArray*items = [NSMutableArray arrayWithArray:existValue];
                    [items addObject:value];
                    [params setValue:items forKey:key];
                }else{
                    //非數組
                    [params setValue:@[existValue,value]forKey:key];
                }

            }else{
                //設置值
                [params setValue:value forKey:key];
            }

        }
    }else {
        //單個參數生成key/value
        NSArray *pairComponents = [self componentsSeparatedByString:@"="];
        if(pairComponents.count==1) {
            return nil;
        }
        //分隔值
        NSString *key = [pairComponents.firstObject stringByRemovingPercentEncoding];
        NSString *value = [pairComponents.lastObject stringByRemovingPercentEncoding];
        //key不能為nil
        if(key ==nil|| value ==nil)return nil;
        //設置值
        [params setValue:value forKey:key];

    }
    return params;
}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

標簽:盤錦 綏化 赤峰 中山 萍鄉 聊城 阿壩 金昌

巨人網絡通訊聲明:本文標題《Html5跳轉到APP指定頁面的實現》,本文關鍵詞  Html5,跳,轉到,APP,指定,頁,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Html5跳轉到APP指定頁面的實現》相關的同類信息!
  • 本頁收集關于Html5跳轉到APP指定頁面的實現的相關信息資訊供網民參考!
  • 推薦文章