React Native
How to integrate the React Native plugin.
You can use this plugin for all React Native games.
Connecting plugin to your project.
To obtain the plugin please connect with us.
Then just import these:
You can use ESCSButton and ESCSWebView as your regular react components in JSX like this:
Integrating plugin into your game.
Initialization
To start using your plugin you need first initialize it:
where:
public_key
- a key that you've obtained in the step 1 of the integration guidebase_url
- url for the core ESCS service. It is https://api.escs.io for production environmentplayer_base_url
- url for the player's ESCS service. It is https://player.escs.io for production environmentanalyticsEnv
- environment to use for analytics reporting
Start/End Game
After that you are all set and ready to use ESCS functionality. To start a game's round, just call startGame()
method:
When the round of your game has ended, just call endGame()
with score parameter:
Probably you would like some additional layer of security sending game results to a server, so you can use encrypted transfer (using symmetric cryptographic key):
where key - is a function, that returns a string key when called. This key you should obtain in your client dashboard described in Anti-Cheat services - look up the "front secret key".
We recommend to obfuscate your key and not store it as a value - that is why endGameEncrypted
is expecting a function, not a value. For example, you can obfuscate string values here: https://anseki.github.io/gnirts/
Optional steps
Hiding ESCS button
Most of the time you will not want to show the ESCS button during the actual game, to not mess with the gameplay, for example user can accidentally touch it and almost full-screen webview will show up. To hide the button you can use its visible
property.
Notifications/Announcements
There are situations, when ESCS needs to show announcements or notifications - for example to promote your game's upcoming championship, or ask user to add credit card, because his/her trial is about to expire. ESCS will open its full WebView automatically to show notification's content, if it's needed. To be able to show these, not interrupting your gameplay and at the times that are not interruptive for user, please call these methods:
There's internal logic in the plugin to decide whether it needs to show actual notification and announcement, but you should place these calls whenever you feel that interruption with ESCS WebView window is okay for user experience.
Please note that it does not mean that user will see notification or announcement every time you call these methods. We are trying for those to be as subtle and fluent as possible for end user. Their names imply that notification/announcement just maybe will be shown.
Additional Considerations
There are often situation when you want to respond somehow to the ESCS service state. You can use getStatus()
method:
which will return object like this:
Logging out
Sometimes you want to log out the user out of the ESCS programmatically, for example when the user logs out of the game. You can use the following call for this:
Last updated