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 theonTokenExpiring callback.
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 theonTokenExpired 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
| Callback | Type | Description |
|---|---|---|
| onTokenExpiring: () => { your code }, | function | Callback event triggered when the used token is about to expire in a few minutes. You would implement getting a new token in this callback. |
| onTokenExpired: () => { your code }, | function | Callback event triggered when the used token has expired. You would implement getting a new token in this callback. |
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 anNSNotification.
CelloTokenAboutToExpire
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 theCelloTokenHasExpired event.
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
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 theTokenHasExpired event.
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
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 thetokenAboutToExpire event.