Open sagivf opened 6 years ago
Are you doing the import * as OT from '@opentok/client'
through typescript? Because the importing is probaly not importing the cordova plugin, but the @types variant of the library which is just the web sdk?
@wolfenrain It is typescript. Your correct it is not importing the cordova plugin, it's loading the web sdk.
That's my issue, it would be nice if using a simple import
would load the cordova code or the web sdk code depending on the platform. Would probably need a third package to handle the differences and recognize when to use cordova code and when to run web code, that's what https://ionicframework.com/docs/native/ does.
So from what I have gathered there are two ways to load the tokbox code/package. 1)
import * as OT from '@opentok/client'
2) add the tokbox script -<script src="opentok.js"></script>
The code loaded in both ways is different. Using (1) will work with in the browser only. Using (2) works on both but to load the script you must be on a cordova platform, so you have to run
cordova run browser
if you want it to work in the browser (ionic serve wont load the script it self).while this works, it would be nice and a lot less confusing if things where simply loaded via a platform agnostic library which would bridge the differences. like https://ionicframework.com/docs/native/ does for other plugins.
I would write this myself but it seems like importing @opentok/client overrides the global OT variable and I don't think you can do conditional imports on ES6 yet.