To get started on using the SDK, please visit the API reference docs.
In addition to existing CDN build, we now have the main Application
object available as an npm package. For more details, see the next section.
Installing the SDK
npm install --save @webex/embedded-app-sdk@2.0.0-beta.1
This will create an entry in your package.json like this:
{
"name": "webex-embedded-app-sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@webex/embedded-app-sdk": "^2.0.0-beta.1"
}
}
Using the SDK
import Application from '@webex/embedded-app-sdk';
const app = new Application();
await app.onReady();
Access anything under the app
object as per the API reference. This can later be bundled with your app by using any bundling tool like webpack or rollup.
Including the SDK
Add the following code in your index.html
<script src='https://unpkg.com/@webex/embedded-app-sdk@2.0.0-beta.1'></script>
The SDK is now included in your app.
Using the SDK
const app = new window.webex.Application();
await app.onReady();
Access anything under the app
object as per the API reference.
Requests from the Embedded App SDK are rate limited by the native client in the following ways:
The Embedded App SDK 2.x allows the user to set and modify the log level at Application instance creation or at a later time. Default log level is set to INFO.
While creating application instance
const config = {
logs: {
logLevel: 0 //INFO: 0, WARN: 1, ERROR: 2, SILENT: 3
}
}
const app = new window.Webex.Application(config); //CDN
OR
const app = new Application(config); //NPM
Using log property on application instance
app.log.updateLogLevel(0); //INFO: 0, WARN: 1, ERROR: 2, SILENT: 3
Webex.Application
objectWebex.Application
object is removed and moved to webex.Application
In 1.x SDK
const app = new window.Webex.Application();
In 2.x SDK
const app = new window.webex.Application();
webex.application
objectThe properties of webex.application
are now private and no longer accessible
In 1.x SDK
const about = webex.application.about;
const capabilities = webex.application.capabilities;
const deviceType = webex.application.deviceType;
In 2.x SDK
const app = new window.webex.Application();
const about = app.about;
const capabilities = app.capabilities;
const deviceType = app.deviceType;
The above list is not exhaustive, and other properties will also require the same change as shown above. All the properties, accessors, methods, and events are documented in the Application
class.
The user
object is now a static object in 2.x SDK and can be directly accessed via the SDK; therefore, the context.getUser()
method is no longer available.
In 1.x SDK
const app = new window.Webex.Application();
app.context
.getUser()
.then((u) => {
log("getUser()", u);
})
.catch((error) => {
log(
"getUser() promise failed with error",
Webex.Application.ErrorCodes[error]
);
});
In 2.x SDK
const app = new window.webex.Application();
await app.onReady();
const user = app.application.states.user;
There are no real-time updates for the user
object, so the event user:infoChanged is no longer emitted.
In 1.x SDK
const app = new window.Webex.Application();
app.onReady().then(() => {
app.listen()
.then(() => {
app.on("user:infoChanged", (user) => {
console.log("User object modified. New Information:", user);
})
})
.catch((reason) => {
console.error("listen: fail reason=" + webex.Application.ErrorCodes[reason]);
});
});
In 2.x SDK
The event is removed and won't be emitted. Any instances of the above code must be removed.