Bigbluebutton 官網(wǎng)文檔:http://docs.bigbluebutton.org/
官方建議PC和手機使用Chrome或者Firefox桐臊、safari瀏覽器打開網(wǎng)頁就可以使用。
問題:現(xiàn)在開發(fā)APP當中仑鸥,用iOS僵芹、安卓內(nèi)核的瀏覽器(Webview)打開網(wǎng)頁會提示版本太低。但是手機瀏覽器是可以正常使用 膛壹。
IOS上面從safari11開始也提供webrtc支持了。全部用瀏覽器打開就好了疼电。包括iOS 用SFSafariViewController打開也是可以支持的,但是用webview或者wkwebView打開會提示版本不支持建議用瀏覽器打開的提示减拭;包括安卓的webview也是有相同問題澜沟;
iOS和安卓的解決辦法:
iOS端? (wkwebView方式):
- (void)setupWKWebView{
? ? UIButton *clickBtn = [[UIButton alloc] initWithFrame:CGRectMake(150, 250, 100, 50)];
? ? clickBtn.backgroundColor = [UIColor yellowColor];
? ? [clickBtn setTitle:@"點擊WKWeb打開" forState:UIControlStateNormal];
? ? clickBtn.titleLabel.textColor = [UIColor blueColor];
? ? [clickBtn addTarget:self action:@selector(clickWKW:) forControlEvents:UIControlEventTouchUpInside];
? ? [self.view addSubview:clickBtn];
? ? WKWebViewConfiguration *webConfiguration = [WKWebViewConfiguration new];
? ? _webView = [[WKWebView alloc] initWithFrame:[UIScreen mainScreen].bounds configuration:webConfiguration];
? ? _webView.UIDelegate = self;
? ? _webView.navigationDelegate = self;
? ? [self.view addSubview:_webView];
? ? _webView.backgroundColor = [UIColor yellowColor];
? ? //修改agent-serve 關鍵點!O恳辍!
? ? NSString *ua = [NSString stringWithFormat:@"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36"];
? ? if (@available(iOS 12.0, *)){
? ? ? ? //由于iOS12的UA改為異步刊苍,所以不管在js還是客戶端第一次加載都獲取不到既们,所以此時需要先設置好再去獲取
? ? ? ? NSString *userAgent = [_webView valueForKey:@"applicationNameForUserAgent"];
? ? ? ? NSLog(@"old-agent serve:%@",userAgent);
? ? ? ? NSString *newUserAgent = [NSString stringWithFormat:@"%@%@",userAgent,ua];
? ? ? ? NSLog(@"new-agent serve:%@",newUserAgent);
? ? ? ? [_webView setValue:newUserAgent forKey:@"applicationNameForUserAgent"];
? ? }
? ? [_webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
? ? ? ? NSString *userAgent = result;
? ? ? ? if ([userAgent rangeOfString:ua].location != NSNotFound) {
? ? ? ? ? ? return ;
? ? ? ? }
? ? ? ? NSString *newUserAgent = [userAgent stringByAppendingString:ua];
? ? ? ? NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent,@"UserAgent", nil];
? ? ? ? [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
? ? ? ? [[NSUserDefaults standardUserDefaults] synchronize];
? ? ? ? //不添加以下代碼則只是在本地更改UA,網(wǎng)頁并未同步更改
? ? ? ? if (@available(iOS 9.0, *)) {
? ? ? ? ? ? [self->_webView setCustomUserAgent:newUserAgent];
? ? ? ? } else {
? ? ? ? ? ? [self->_webView setValue:newUserAgent forKey:@"applicationNameForUserAgent"];
? ? ? ? }
? ? }];
//加載請求必須同步在設置UA的后面
? ? NSURL *url = [NSURL URLWithString:_pathUrl];
? ? NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
? ? [_webView loadRequest:request];
}
安卓端(webview):
安卓代碼加下面的內(nèi)容(似乎是將瀏覽器定義成PC瀏覽器來使用)
WebSettings settings = webView.getSettings();
?settings.setUserAgentString("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36");