GithubHelp home page GithubHelp logo

solar2d / com.solar2d-plugin.huaweiaccountkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evilminddevs/com.solar2d-plugin.huaweiaccountkit

0.0 1.0 1.0 160 KB

License: MIT License

Lua 5.38% Kotlin 57.55% Java 37.07%

com.solar2d-plugin.huaweiaccountkit's Introduction

Huawei Account Kit Solar2d Plugin

This plugin was created based on Huawei Account Kit. Please check for detailed information about Huawei Account Kit.

In order to use the Huawei Account kit, first you must create an account from developer.huawei.com. And after logging in with your account, and then you must create a project in the huawei console in order to use HMS kits.

Project Setup

To use the plugin please add following to build.settings

{
    plugins = {
        ["plugin.huaweiAccountKit"] = {
            publisherId = "com.solar2d",
        },
    },
}

And then you have to create keystore for your app. And you must generate sha-256 bit fingerprint from this keystore using the command here. You have to define this fingerprint to your project on the huawei console.

And you must add the keystore you created while building your project. Also you need to give the package-name of the project you created on Huawei Console. And you need to put agconnect-services.json file into main.lua directory.

After all the configuration processes, you must define the plugin in main.lua.

local accountKit = require "plugin.huaweiAccountKit"

local function listener(event)
    print(event) -- (table)
end

accountKit.init(listener) -- sets listener and inits HMS plugin

We should call all methods through accountKit object. And you can take result informations from listener.

Methods in the Plugin

signIn

Used for login operation. And you need pass 2 parameter. First one is authorization Parameter.

  • DEFAULT_AUTH_REQUEST_PARAM_GAME
  • DEFAULT_AUTH_REQUEST_PARAM

Second one is information requests. Table type.

  • setAuthorizationCode
  • setAccessToken
  • setEmail
  • setId
  • setIdToken
  • setProfile
  accountKit.signIn("DEFAULT_AUTH_REQUEST_PARAM_GAME", {"setAuthorizationCode", "setAccessToken"})

    --Result 
    --[[Table {
              isError = true|false
              message = text
              type = signIn (text)
              provider = Huawei Account Kit
              data = {
                  getDisplayName,
                  getEmail,
                  getFamilyName,
                  getGivenName,
                  getAvatarUri,
                  ...
          }
        } 
    ]]--

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.

  • DEFAULT_AUTH_REQUEST_PARAM_GAME
  • DEFAULT_AUTH_REQUEST_PARAM

Information Requests (Optional)

  • setAuthorizationCode
  • setAccessToken
  • setEmail
  • setId
  • setIdToken
  • setProfile
  accountKit.silentSignIn("DEFAULT_AUTH_REQUEST_PARAM_GAME")

    --Result 
    --[[Table {
              isError = true|false
              message = text
              type = silentSignIn (text)
              provider = Huawei Account Kit
              data = {
                  getDisplayName,
                  getEmail,
                  getFamilyName,
                  getGivenName,
                  getAvatarUri,
                  ...
          }
        } 
    ]]--

signOut

The signOut method is called to sign out from a HUAWEI ID.

    accountKit.signOut()

    --Result 
    --[[Table {
      isError = true|false
      message = text
      type = signOut (text)
      provider = Huawei Account Kit (text)
    }]]--

cancelAuthorization

cancelAuthorization method is used to revoke authorization to improve privacy security on the app.

    accountKit.cancelAuthorization()

    --Result 
    --[[Table {
      isError = true|false
      message = text
      type = cancelAuthorization (text)
      provider = Huawei Account Kit (text) 
    }]]--

Requirement

SDK Platform 19 or later

References

HMS Account Kit https://developer.huawei.com/consumer/en/hms/huawei-accountkit/

License

MIT

com.solar2d-plugin.huaweiaccountkit's People

Contributors

kayahanbaskeser avatar shchvova avatar

Watchers

 avatar

Forkers

agramonte

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.