Closed jsfan3 closed 5 years ago
It could be related to the URL you provide in
Display.getInstance().setProperty("android.WebView.grantPermissionsFrom", testWebRTC);
This value will be compared against getOrigin[https://developer.android.com/reference/android/webkit/PermissionRequest.html#getOrigin()]
It is possible that this just expects the domain portion. E.g. https://demo.kasperkamperman.com
You can provide multiple values to allow here by adding them space-delimited. E.g.
Display.getInstance().setProperty("android.WebView.grantPermissionsFrom", https://demo.kasperkamperman.com https://demo.kasperkamperman.com/ https://demo.kasperkamperman.com/ https://demo.kasperkamperman.com/mobilecamtemplate/");
My money's on just "https://demo.kasperkamperman.com"
Thank you for the reply, but your suggestions didn't work. I tried a new build with Display.getInstance().setProperty("android.WebView.grantPermissionsFrom", "https://demo.kasperkamperman.com https://demo.kasperkamperman.com/ https://demo.kasperkamperman.com/ https://demo.kasperkamperman.com/mobilecamtemplate/");
and another build withDisplay.getInstance().setProperty("android.WebView.grantPermissionsFrom", "https://demo.kasperkamperman.com");
, but both of them produce the same issue.
Please note that the test case I provided doesn't work in Android neither in iOS.
Looking at the log, the origin is "https://demo.kasperkamperman.com/" So you can get away with
Display.getInstance().setProperty("android.WebView.grantPermissionsFrom("https://demo.kasperkamperman.com/");
Also, did you add all of the appropriate permissions in the manifest that were described by the OP in https://stackoverflow.com/questions/43541962/implementing-webrtc-on-webview-with-codename-one ?
I ran across this sample for webrtc that might be helpful. Not sure if you've seen it yet. https://github.com/googlearchive/chromium-webview-samples/tree/master/webrtc-example
Particularly the app manifest file to see the permissions that he grants.
It is possible that we need to request permissions at runtime for Android 6+, but I'm not sure. Try getting it working on an android 5 device (or simulator) first as that would rule this out.
@jsfan3 Did you manage to get this working? Is there something we still need to do to resolve this?
WebRTC cannot be used inside a BrowserComponent, because Apple doesn’t allow that, their implementation of WebRTC is working in Safari only, but not inside an app. I don’t remeber details found in StackOverflow, however Codename One cannot support WebRTC because that.
For reference, these are the sources of my previous comment, even the last iOS (in 2019) doesn't full support WebRTC inside WKWebView, that's why I close my question (I'm not more interested in use WebRTC in Android, because I needed that in both Android and iOS, but it's not possible):
https://stackoverflow.com/questions/45055329/does-webkit-in-ios-11-beta-support-webrtc/49467964#49467964 https://forums.developer.apple.com/thread/88052#thread-message-278803
I'm trying to use WebRTC. I suppose that the right way is
BrowserComponent
plus Javascript-Java bridge. But it doesn't work in Android neither in iOS.I found this nice example that targets mobile browsers and that works very well in Chrome (on Android) and Safari (on iPhone): https://demo.kasperkamperman.com/mobilecamtemplate/
The full source of that example is here: https://github.com/kasperkamperman/MobileCameraTemplate
In StackOverflow, at the page https://stackoverflow.com/questions/43541962/implementing-webrtc-on-webview-with-codename-one, it's suggested to use
android.WebView.grantPermissionsFrom
. (There is no mention of what we need to do in iOS).I tried the following test code in Android (both with a release build and a debug build), but in the native log I get a "class not found exception":
and also:
There are other exceptions, like this:
Another relevant part of the log is this (generated by javascript):
This is the test code:
and this is the native log of an Android 7 device: