-
|
Hi, I am trying to get this working with skip-web. It looks like they require WebChromeClient. I've tried forking skip-web but I am unable to get it to work. Any tips or suggestions? https://docs.videosdk.live/prebuilt/guide/prebuilt-video-and-audio-calling/quick-start-android |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
When you say you are unable to get it to work, were you encountering errors that you might share with us? Or did addition of the myWebView.setWebViewClient(new WebViewClient());
myWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onPermissionRequest(final PermissionRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
request.grant(request.getResources());
}
}
});
For experimentation, you also might be better off just bringing in your own simpler WebView wrapper, like the one at https://github.com/skiptools/skipapp-weather/blob/main/Sources/SkipWeather/WebView.swift. That will at least allow you to tweak various parts without needing to deal with the complexity of the In any case, I think the implementation would look something like this: #if SKIP
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.compose.runtime.Composable
import androidx.compose.ui.viewinterop.AndroidView
struct WebView: View {
let url: URL
let enableJavaScript: Bool
init(url: URL, enableJavaScript: Bool = true) {
self.url = url
self.enableJavaScript = enableJavaScript
}
@Composable public override func ComposeContent(context: ComposeContext) {
AndroidView(factory: { ctx in
let webView = WebView(ctx)
webView.webViewClient = WebViewClient()
webView.webChromeClient = GrantAnyPermissionChromeClient()
webView.settings.javaScriptEnabled = enableJavaScript
return webView
}, modifier: context.modifier, update: { webView in
webView.loadUrl(url.absoluteString)
})
}
}
final class GrantAnyPermissionChromeClient: android.webkit.WebChromeClient {
init() {
}
override func onPermissionRequest(request: android.webkit.PermissionRequest) {
request.grant(request.getResources())
}
}
#endif |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I tried two ways first I tried modifying SkipWeb but this resulted in a white screen not loading anything. You can see the changes here: skiptools/skip-web@main...ajayjapan:skip-web:main Then I also tried the SkipWeather way but was unable to get it to compile. Here are the two errors: Any help would be much appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
-
|
Yes I have the android.permission.INTERNET in my AndroidManifest.xml. www.google.com seems to load fine in the android simulator. It looks to me like the page is loading but not displaying properly, as the i look at the Videosdk dashboard and it registers that someone is viewing the page. Tried using SKIP_BRIDGE. Still getting the same errors. Here is the relevant code: https://gist.github.com/ajayjapan/50f80a9d43ed910c0bc7ad5bd1bb1837 The skip-web loads the page fine in iOS. |
Beta Was this translation helpful? Give feedback.
When you say you are unable to get it to work, were you encountering errors that you might share with us? Or did addition of the
WebChromeClientsimply not work for your needs? It looks like the code they say you need to use could be fairly straightforward to get working with Skip's Kotlin-ish syntax:For experimentation, you also might be better of…