iOS H5(Safari)唤醒App 跳转对应的VC

  1. 在Info-URL Types 配置

URL - Schemes — test
然后跟h5约定 他们回传使用 test:// 开头的一串字符串

  1. 在AppDelegate中
	- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options { }

把带参数URL解析成字典, 传给对应的VC

	NSArray *hostArr = [url.absoluteString componentsSeparatedByString:@"?"];
    if (hostArr.count <= 1) {
        return;
    }
    NSArray *kvArr = [hostArr.lastObject componentsSeparatedByString:@"&"];
    NSMutableDictionary *newDic = [NSMutableDictionary new];
    for (NSString *kv in kvArr) {
        NSArray *arr = [kv componentsSeparatedByString:@"="];
        NSString *value = arr[1];
        [newDic setObject:[value stringByRemovingPercentEncoding] forKey:[arr firstObject]];
    }
上一篇:C++中的一些用法


下一篇:C语言程序的错误和警告