onConnectionStatus handler¶
Responsible for handling the connection status to the voice project in the Alan Cloud.
Depending on the current connection state, the Alan Cloud returns one of the following statuses:
authorized: a request to connect to the voice project is authorized
auth-failed: a request to connect to the voice project is not authorized
connected: a connection to the voice project in the Alan Cloud is established
disconnected: a connection to the voice project in the Alan Cloud is closed
invalid-auth-response: an invalid authentication response is received
Note
At present, the onConnectionStatus
handler is supported only for the Web platform (including cross-platform frameworks, for example, Ionic).
Examples¶
alanBtn({
key: 'YOUR_KEY_FROM_ALAN_STUDIO_HERE',
onConnectionStatus: function(status) {
console.log("The status is " + status);
},
});
Ionic Angular
this.alanBtnComponent.nativeElement.addEventListener('connectionStatus', (data) => {
const connectionData = (<CustomEvent>data).detail;
console.info('Received status: ', connectionData);
});
Ionic React
alanBtnComponent.current.addEventListener('connectionStatus', (data: CustomEvent) => {
const connectionData = data.detail;
console.info('Received status: ', connectionData);
});
Ionic Vue
<ion-content :fullscreen="true">
<alan-button v-on:connectionstatus="connectionstatus" alan-key="YOUR_KEY_FROM_ALAN_STUDIO_HERE" />
</ion-content>
export default defineComponent({
methods: {
connectionstatus: function(data:any) {
console.info('Received status: ', data.detail);
}
},
});