opentok / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
MIT License
30 stars 80 forks source link

Incompatible Browser on IOS and getUserMedia error #168

Open ufuksuu opened 5 years ago

ufuksuu commented 5 years ago

I have an error on iOS when I tried to publish my video. I have followed each step in the Running the Application section for iOS.It s working on Safari when I tried ionic serve.But on iPhone 36440023-4883e506-1634-11e8-8d31-fbb398bca384 and I saw a couple of errors on console. Ekran Resmi 2019-06-13 10 42 48

abhilashbr92 commented 4 years ago

@ufuksuu Even i have the same error. Did you find any solution?

phiferd commented 4 years ago

That happened to me when I tried to use the JS plugin (for web) rather than the cordova plugin's js file. The cordova plugin will put a new .js file in the www directory of your app, so you should include a line like this:

<script type="text/javascript" charset="utf-8" src="opentok.js"></script>

Note that the script tag references a javascript file that doesn't exist until the project is built for iOS.

If you want to be able to develop in the browser, you either need to put the web version there, or include the following

<script type="text/javascript" charset="utf-8" src="opentok.js"></script>
<script type="text/javascript">window.OT || document.write(`<script src="https://static.opentok.com/v2/js/opentok.min.js">\x3C/script>`)</script>

This extra script tag checks to see if window.OT is defined. If it is, then you're running on the device and the build must have inserted the opentok.js into www and it's basically a no-op. If window.OT is not defined, then it adds a new script tag to the document as a fallback.