Fired when the client has been destroyed via Client.destroy. All event listeners are removed after this event is emitted.
Fired when the aggregate connection state of the SDK changes — reflecting network health and the state of any initialized SDKs (Conversations, Voice, TaskRouter). The handler receives the new SdkConnectionState.
Fired approximately one minute before the session token expires, giving the application a window to supply a fresh token via Client.updateToken. The threshold matches the SDK's internal auto-refresh window. Emitted at most once per token.
This fires whether or not auto-refresh (autoUpdateToken) is enabled, so applications
that manage token refresh themselves can renew the token in time. The handler receives
the Date at which the token will expire.
import { createClient, ClientEvent } from "@twilio/flex-sdk";
const client = await createClient("SDK_TOKEN", { session: { autoUpdateToken: false } });
client.on(ClientEvent.TokenAboutToExpire, async (dateExpiring) => {
const freshToken = await fetchNewToken();
client.updateToken(freshToken);
});
Fired when automatic token refresh (autoUpdateToken) fails to obtain or apply a new
token. The existing token stays in place until it is replaced or expires.
Fired when the session token has passed its expiry time without a valid replacement having been applied. Emitted at most once per token.
When auto-refresh (autoUpdateToken) is enabled and renews the token before expiry,
this event does not fire. It is primarily useful for applications that manage token
refresh themselves, or that need to react to an expired session (for example, by
prompting the user to re-authenticate). The handler receives the Date at which
the token expired.
Fired when a refresh can no longer extend the token's expiry because its maximum
lifetime has been reached. The handler receives the Date at which the token expires.
Fired after the session token is updated — either by a manual Client.updateToken call or a successful auto-refresh — and propagated to all connected services. The handler receives the new token and, when available, the new refresh token.
Enumeration of event names that the Flex SDK client can emit.