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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/sinat_30162391/article/details/102759201
  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]];
    }

猜你喜欢

转载自blog.csdn.net/sinat_30162391/article/details/102759201
今日推荐