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 *)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]];
    }

你可能感兴趣的:(Objective-C成长之路)