Initialization
OnSched.js is initialized by passing your clientId and environment to the OnSched function. OnSched.js will then connect to the API and return an access token to be used by the elements.
After initialization, get instance of elements to use for creating all OnSched.js elements. See the elements tab for more information.
/// Initialize OnSched.js
/// Param 1 - Your API ClientId.
/// Param 2 - "sbox" for sandbox testing
/// "live" for production
///
/// NOTE - you must register your domain for authorization. see Overview for more details.
///
const onschedOptions = {};
const onsched = OnSched("<<clientId>>", "sbox", onschedOptions);
/// Get instance of elements to use for creating elements
const elements = onsched.elements();
Initializing from a Mobile App
When initializing OnSched.js from an IOS or Android application without a WebView the element will need to be loaded without any Domain Validation (explained in the Overview tab). In order to circumvent the domain validation requirement you must gather a token to include in the onschedOptions object as a value for the property access_token.
/// Initialize OnSched.js
/// Param 1 - Your API ClientId.
/// Param 2 - "sbox" for sandbox testing
/// "live" for production
///
/// Options
/// Param 1 - access_token: Obtain access token from the OnSched Identity API.
/// For more informaiton about obtaining a token please see https://docs.onsched.com/docs/authentication
const onschedOptions = { access_token: 'abc123' };
const onsched = OnSched("<<clientId>>", "sbox", onschedOptions);
/// Get instance of elements to use for creating elements
const elements = onsched.elements();
Updated 4 months ago
What’s Next