Skip to main content
By default, tokens are long-lived and do not expire. However, you can choose to have your tokens expire every 24 hours for enhanced security. In that case, Cello considers tokens created more than 24 hours ago expired and therefore invalid. You can deal with the timing yourself, but the preferred way is to handle onTokenExpiring and onTokenExpired events by assigning your callbacks via the boot command. We provide special updateToken SDK command for that.

updateToken(token)

Updates the token that the library is using. Should usually be called after Cello has indicated the token is starting to expire with the onTokenExpiring callback.
To provide a seamless experience for the user, the implementation should mint a new token before the previous token expires. To help customers detect these situations and avoid relying on custom timers, Cello provides two callback events that a developer can add to the cello.boot command.

onTokenExpiring

This callback is called when Cello detects that the token in use is going to expire in 5 minutes. This should leave enough time to mint a new token and register it with Cello.

onTokenExpired

It may still happen that the time to expiration has passed - for example, when a user has been offline and reopens their laptop. In that case, Cello triggers the onTokenExpired callback. In most cases, a developer should assign both of the above events and implement the same routines there. The separation is meant for special cases when developers want to do different things (like logging) depending on the situation.

Example of the whole flow

Cello for iOS

To provide a seamless experience for the user of iOS app, the implementation should mint a new token before the previous token expires. To help customers detect these situations and not need to rely on custom timers, Cello provides two events which you can listen to for updates by observing an NSNotification.

CelloTokenAboutToExpire

This event is triggered, when Cello detects that the used token is going to expire in 5 minutes. This should leave enough time to mint a new token and register it with Cello.

CelloTokenHasExpired

It may still happen that the time to expiration has passed, for example, when a user has been offline and reopens their laptop. In that case, Cello triggers the CelloTokenHasExpired event.
In most cases, a developer should assign both of the above events and implement the same routines there. The separation is meant for special cases when developers want to do different things (like logging) depending on the situation.

Cello for Android

To provide a seamless experience for the user, the implementation should mint a new token before the previous token expires. To help customers detect these situations and not need to rely on custom timers, Cello provides two events which you can listen to for updates.

addTokenAboutToExpireListener

This event is triggered, when Cello detects that the used token is going to expire in 5 minutes. This should leave enough time to mint a new token and register it with Cello.

addTokenExpiredListener

It may still happen that the time to expiration has passed, for example, when a user has been offline and reopens their laptop. In that case, Cello triggers the TokenHasExpired event.
In most cases, a developer should assign both of the above events and implement the same routines there. The separation is meant for special cases when developers want to do different things (like logging) depending on the situation.

Cello for React Native

To provide a seamless experience for the user, the implementation should mint a new token before the previous token expires. To help customers detect these situations and not need to rely on custom timers, Cello provides two events which you can listen to for updates.

tokenAboutToExpire

This event is triggered, when Cello detects that the used token is going to expire in 5 minutes. This should leave enough time to mint a new token and register it with Cello.

tokenHasExpired

It may still happen that the time to expiration has passed, for example, when a user has been offline and reopens their app. In that case, Cello triggers the tokenAboutToExpire event.
In most cases, a developer should assign both of the above events and implement the same routines there. The separation is meant for special cases when developers want to do different things (like logging) depending on the situation.