Getting client app version



  • Hi!
    How can we get the client app version (sometimes referred to as the gameVersion) into a BrainCloud script (for the current session)?


  • brainCloud

    Hmm, interesting question - I don't believe that value is currently made available - though I could definitely see it being useful for scripts. I'll discuss with the devs.

    In the meantime, you can get this info by creating a post-hook for the Authenticate call.

    The script that you hook into the call will receive the appVersion (field "gameVersion" internally) as a STRING in a "data.callingMessage.gameVersion" field.

    I've attached a sample script that stores the gameVersion to the session cache (and writes a log message stating the gameVersion received).

    To try it:

    • Import the script
    • Go to Design | Cloud Code | API Hooks and configure the hook as a POST hook for the Authenticate service, Authenticate Operation
    • Go to the API Explorer and do a test login. Be sure to set the "appVersion" in the JSON (by default it is "").
    • Info Messages, hit [Refresh] to see the log with your app version.

    Hope that helps!

    Paul.

    LogIncomingAppVersion.ccjs



  • Thank you for your answer. Yes, it will be nice to have a separate API but for now, the solution suggested by you works for us.