| 说明 | 参数 | 介绍 |
|---|---|---|
| 活动id | room_id | 对应微吼直播活动id ,必填参数 |
| 活动口令 | password | 主持人和嘉宾对应的参会口令 ,必填参数 |
| 角色 | role_name | 1:主持人 4:嘉宾 ,必填参数 |
| 昵称 | nick_name | 参会活动的昵称,role_name=1时内容为空,role_name=4作为嘉宾需要携带昵称或在app参会页面进行手动填写 |
val uri = Uri.parse("vhlive://com.vhall.vhlive.broadcast")
.buildUpon()
.appendQueryParameter("room_id", "808101212")
.appendQueryParameter("password", "123456")
.appendQueryParameter("role_name", "1")
.appendQueryParameter("nick_name", "")
.build()
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(intent) NSURL *baseUrl = [NSURL URLWithString:@"vhlive://com.vhall.vhlive.broadcast"];
if (!baseUrl) {
NSLog(@"URL 格式错误");
return;
}
NSURLComponents *components = [NSURLComponents componentsWithURL:baseUrl resolvingAgainstBaseURL:NO];
components.queryItems = @[
[NSURLQueryItem queryItemWithName:@"room_id" value:@"808101212"],
[NSURLQueryItem queryItemWithName:@"password" value:@"123456"],
[NSURLQueryItem queryItemWithName:@"role_name" value:@"4"],
[NSURLQueryItem queryItemWithName:@"nick_name" value:@"嘉宾"]
];
NSURL *targetUrl = components.URL;
if (!targetUrl) {
NSLog(@"参数拼接失败");
return;
}
// 3. 检查并唤起
if ([[UIApplication sharedApplication] canOpenURL:targetUrl]) {
[[UIApplication sharedApplication] openURL:targetUrl options:@{UIApplicationOpenURLOptionsUniversalLinksOnlyKey: @NO} completionHandler:^(BOOL success) {
if (success) {
NSLog(@"唤起成功");
} else {
NSLog(@"唤起失败");
}
}];
} else {
// 提示未安装
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"未安装直播 App,请先下载" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}