API Reference

List of functions and variables exposed by the Stagecast object, the entry point to the MDK library.

In case you want to code right away, you can check out the tutorial section and come back here later.

Introduction

The Stagecast object is library entry point and comes with some getter function that allows to access the Moment context data. The context data is grouped in the general getters section.

You can also get directly to the sub sections:

General Getters

Your HTML-based application will get its running context from the Moment. The moment is derived from a MomentClass which belongs to a specific Event.

getEventId(): string

const eventId = SDK.getEventId();
console.log(eventId); // prints "1234-5678-90123-4567"

Returns the current event id. The id is a UUIDv4.

getUserId(): string

const userEmail = SDK.getUserId();
console.log(userEmail); // prints "user@stagecast.io"

Returns the User identification which most of the times is the email.

getMomentId(): string

const momentId = SDK.getMomentId();
console.log(momentId); // prints "12345-45677-ABCDE-12345"

Returns the Moment id as a string. The id is a UUIDv4.

getMomentClassId(): string

const momentClassId = SDK.getMomentClassId();
console.log(momentClassId); // prints "12345-45677-ABCDE-12345"

Returns the MomentClass id. The id is a UUIDv4.

isActive(): boolean

Tells whether the Moment is active or not, ie. whether the moment has been stopped by the event organizer from the launchpad. It can be used to render different views, for example:

if (SDK.isActive()) {
  renderMainPage();
} else {
  renderOtherPage();
}

Often, this is used to display the moment results. An example could be a poll: as long as isActive() returns true the user can express a vote. When the moment stops and isActive() return false, the application could display the poll results or just the user vote.

getCoordinates(): [lat, long]

This function returns the user coordinates as an array of string where the first entry is the latitude and the second is the longitude. The coordinates can be used to activate some functionality depending on the user's location.

In case the wrapper mobile app, or the wrapper website can't get this values, the default ['0', '0'] is returned.

The bannerInjector object

injectAdvertisementBanner(selectors: string[])

The function injects the credits text and the sponsor logos specified in the Moment Class configuration window in the organizer dashboard.

If your moment doesn't support branding, you will have to specify that in the MANIFEST.json.

Params:

  1. selectors: list of CSS3 selectors in which the advertisement images will be injected.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Test</title>
  </head>
  <body>
    <div id="sponsorsAnchor1"></div>
  </body>
  <!-- Js Scripts Import -->
  <script src="https://stagecast.se/media/lib/mdk/stagecast.min.js"></script>
  <script src="./main.js"></stript>
</html>

Last updated