'sessionWillRenewAccessToken' of undefined

Hi friends,

I have a problem with sessionWillRenewAccessToken after upgrading to @amityco/ts-sdk@0.0.1-beta.38 to be able to use livePost() observer.

My react-native app crashes after a few minutes and this error comes up on the red screen:
ERROR TypeError: Cannot read property 'sessionWillRenewAccessToken' of undefined, js engine: hermes

Is there any solution to fix it?

Hey @Tech,

Looks like it happening because the sessionHandler is missing. You can check the docs here.

When calling connectClient pass the session handler. Example:

  import { connectClient } from '@amityco/ts-sdk';

  const sessionHandler: Amity.SessionHandler = {
    sessionWillRenewAccessToken(renewal) {

  const handleConnect = async (userId: string, displayName: string) => {
    await connectClient({ userId, displayName }, sessionHandler);

  handleConnect('userId', 'Bob Newton');

You can read more about Access Token Renewal here

1 Like