Handle Authorization
Once the CWIC library has been initialized, user will be prompted with ACD (Access Control Dialogue). User needs to
press accept button on ACD, otherwise UserNotAuthorized will be passed in errorHandler for any
CWIC API call that is made. In order to know whether user has accepted or rejected ACD, event handler
for "onAuthorized" and
"onAuthorizationRejected" events must be set. Since these
events are fired right after initialization has been successful, event handlers must be set before calling
initialize.
// Our event handler function for 'onAuthorized'
function onAuthorized()
{
// Rest of the API can now be safely used...
}
// Our event handler function for 'onAuthorizationRejected'
function onAuthorizationRejected()
{
// Handle event...
]
// Registration of event handlers.
cwic.SystemController.addEventHandler('onAuthorized', onAuthorized);
cwic.SystemController.addEventHandler('onAuthorizationRejected', onAuthorizationRejected);
// Calling API to initialize cwic library.
cwic.SystemController.initialize();