Import Library
In order to develop applications that support Stagecast Moments, the MDK must be imported before your javascript code.
<!-- Fetch the library code from the Stagecast CDN -->
<script src="https://stagecast.se/media/lib/mdk/stagecast.min.js"></script>
Once the code is imported:
let SDK = new Stagecast({...config});
SDK.onConfigReceived(myCallback);
function myCallback() {
console.log('Moment has loaded');
}
The MDK is an empty wrapper for the Stagecast Backend APIs that needs some runtime configurations to be injected. The configuration object looks like the following:
{
environment: 'prod',
userId: 'user@stagecast.se',
token: <api_token>,
momentClassData: {...},
momentClassId: <moment_class_id>,
momentId: <moment_id>,
eventId: <event_id>,
coordinates: ['0', '0'],
isGuest: true,
isActive: true,
isMomentActive: true
}
NOTES
Some default configurations can be passed via object constructor. But beware that the Stagecast App will send the runtime configuration to the SDK when the moment is launched in the Mobile apps.
onConfigReceived(callback)
is always fired after the page has loaded. Of cource, if you need to perform some actions before thewindow.load
event, you can.
Last updated
Was this helpful?