Gameanalytics.com requires me to have a different game (with it’s own key) for each platform. So this means that I have two keys. One for iOS and one for Android.
However in the Lua code in my game I can only initialise the Gameanalytics plugin with one key.
Is it best practice to use system.getInfo(“platform”) to retrieve the current platform (iOS or Android) and then initialise the Gameanalytics plugin with the corresponding key? Or is there any other best practice?
That’s almost exactly how I ended up implementing it. Nice to know that I was on the right track.
Thanks so much!
I also noticed that switching between the two keys on the same device during Live Build, has some unexpected behaviour. Can it be that there is some caching going on? I know that this is not relevant anymore with the current implementation strategy, but I was just curious.
Live builds has no idea what your code is actually doing. It simply detects changes and tells the device to reload. If your code isn’t doing platform detection, it has no way to pick which API key to use, so if you have an android key selected and live builds reloads the iOS app with the Android key. The device detection code assures the right key will be used when the app reloads.
I understand, but this behaviour occurred before I implemented the device detection. E.g. I had Live build on an iOS device with the iOS API key. Events are being sent to my iOS game account in Game Analytics as expected. I then manually change the API key to the Android API key. After the Live build syncs, the events are still being sent to my iOS game account. Only after I remove the App from my phone and reset Live build, the events are being sent to my Android game account in Game Analytics.
However, I have to reproduce this to make a good case, but I think it is not so relevant, because this is a situation that should not occur in real life.