HMS Account Kit | Solar2D
Hi everyone,
In this article, I will mention how to use HMS Account Kit on Solar2D.
First of all, we should create a Solar2D project and import plugin to “build.settings” file. If you do not have enough information about HMS Solar2D plugin integration, I recommend you to read this article. HMS Solar2D Plugin Integration
Let’s start after completing the HMS integration.
First we need to import plugin to build.settings file.
And we need to specify minSdkVersion in build.settings file for HMS Account Kit.
Note : Don`t forget to place “agconnect-services.json” file in main.lua directory.
After all the configuration processes, we must define the plugin in main.lua.
We should call all methods through accountKit object. And you can take result information from listener.
Methods in the Plugin
signIn
Used for login operation. And you need pass 2 parameters.
First one is authorization Parameter. (String)
- DEFAULT_AUTH_REQUEST_PARAM_GAME
- DEFAULT_AUTH_REQUEST_PARAM
Second one is information requests. (Table).
- setAuthorizationCode
- setAccessToken
- setEmail
- setId
- setIdToken
- setProfile
silentSignIn
silentSignIn method allows users to use the same HUAWEI ID without authorization for subsequent sign-ins. And you should pass authorization parameter and information requests. Information requests are optional.
Authorization Parameter. (String)
- DEFAULT_AUTH_REQUEST_PARAM_GAME
- DEFAULT_AUTH_REQUEST_PARAM
Information Requests (Table)(Optional)
- setAuthorizationCode
- setAccessToken
- setEmail
- setId
- setIdToken
- setProfile
signOut
The signOut method is called to sign out from a HUAWEI ID.
cancelAuthorization
cancelAuthorization method is used to revoke authorization to improve privacy security on the app.
By processing the results that return to the Listener method, you should integrate account kit methods according to your project.
And you can examine the sample project from the following repository.
I hope this article was useful.