How to use live query in Unity

I created a sync to watch for an ERC20 token approval event and this works perfectly fine in that I can see the entries in DB for each approval.
Now, in Unity I’m trying to add listener that would inform an app that even has been created/updated but nothing gets over to Unity.
The sync name (and DB table) in Moralis is “TUSDCoinApprovalCronos”
here is how I do it Unity:

public class TUSDCoinApprovalCronos: MoralisObject
    {
        public string spender { get; set; }
        public bool confirmed { get; set; }

        public TUSDCoinApprovalCronos() : base("TUSDCoinApprovalCronos")
        {
            
        }
}

then subcribtion is done like that:

       private async void SubscribeToDatabaseEvents()
        {
            Debug.Log("SubscribeToDatabaseEvents called");
            var callbacks = new MoralisLiveQueryCallbacks<TUSDCoinApprovalCronos>();
            callbacks.OnConnectedEvent += (() => { Debug.Log("Connection Established."); });
            callbacks.OnSubscribedEvent += ((requestId) => { Debug.Log($"Subscription {requestId} created."); });
            callbacks.OnUnsubscribedEvent += ((requestId) => { Debug.Log($"Unsubscribed from {requestId}."); });
            callbacks.OnErrorEvent += ((ErrorMessage em) =>
            {
                Debug.Log($"ERROR: code: {em.code}, msg: {em.error}, requestId: {em.requestId}");
            });
            callbacks.OnCreateEvent += ((item, requestId) =>
            {
                Debug.Log($"Created ");
            });
            callbacks.OnUpdateEvent += ((item, requestId) =>
            {
                Debug.Log($"Updated ");
            });
            callbacks.OnDeleteEvent += ((item, requestId) =>
            {
                Debug.Log($"Hero deleted");
            });
            callbacks.OnGeneralMessageEvent += ((text) =>
            {
                Debug.Log($"Websocket message: {text}");
            });

            var q = await Moralis.GetClient().Query<TUSDCoinApprovalCronos>();
            MoralisLiveQueryController.AddSubscription<TUSDCoinApprovalCronos>("TUSDCoinApprovalCronos", q, callbacks);
        }

given that I see the following in the logs:

SubscribeToDatabaseEvents called
Websocket message: Sending connection request.
Websocket message: Listening, status: New
Websocket message: Result received.
Websocket message: Received message $connected
Connection Established.
Websocket message: Processed connected.
Websocket message: Sending subscription request.
Websocket message: Listening, status: Opening
Websocket message: Received message $subscribed
Subscription 1 created.
Websocket message: Processed subscribed.
Websocket message: Listening, status: Open

I know the subscription itself is OK.
So the questions are:

  • is my fundamental assumption that Moralis ERC20 Approval Sync triggers an event correct? (I use events from custom tables already in the project)
  • if so what is the correct event name triggered? I tried both TUSDCoinApprovalCronos (as per DB name) and TUSDCoinApprovalCronosEvent as I’ve seen somewhere on tutorial that Event as post-fixed to the table name.
  • if one of the above names is correct then what else do I do wrong…

Any help greatly appreciated as I spent hours trying to get that to work.

I know how it should be done in vanilla js, there you use the exact table name that is in the database, and you also use on update

you could also make a query every x seconds if you don’t find a better option

Tried the exact table name already but onUpdate never get triggered unfortunately; and yes, pulling is an option but pretty poor one so probably only going to use it as the last resort.

Alright I can confirm that the event name is indeed not post-fixed with anything (which makes sense if in JS is the same) so in my case it’s just TUSDCoinApprovalCronos .
The problem was with my setup - I’ve recently moved servers and must have updated the connection settings while game was running in Unity which gets revered when game is stopped. Quite embarrassing really…