5.0.0-300 • Published 4 years ago

react-native-hms-account v5.0.0-300

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 years ago

react-native-hms-account

Contents

  1. Introduction
  2. Installation Guide
  3. Function Definitions
  4. Configuration & Description
  5. Licencing & Terms

1. Introduction

This plugin enables communication between Huawei Account kit and React Native platform.

  • Android: core layer, bridging Huawei's Account Kit bottom-layer code.
  • src/modules: Android interface layer, exposes Modules and methods to React Native.
  • index.js: external interface definition layer, which is used to define interface classes or reference files.

2. Installation Guide

  • Go to your app's directory
cd example/
  • Install
npm i
  • Copy Library
npm run react-native-hms-account

After copying, the structure should be like this

  • Download the module and copy it in your demo project's 'node_modules' folder. The folder structure is shown below;
project-name
    |_ node_modules
        |_ ...
        |_ react-native-hms-account
        |_ ...
  • Add HMSAccount package to your application
import com.huawei.hms.rn.account.HmsAccountPackage;
  • Add the following line to your getPackages() method.
packages.add(new HmsAccountPackage());

Copy the agconnect-service.json file to the android/app directory of the demo project.

  • Create an app by referring to Creating an AppGallery Connect Project and Adding an App to the Project.

  • A signing certificate fingerprint is used to verify the authenticity of an app when it attempts to access an HMS Core (APK) through the HMS SDK. Before using the HMS Core (APK), you must locally generate a signing certificate fingerprint and configure it in AppGallery Connect. For details, please refer to Generating a Signing Certificate.

  • Sign in to AppGallery Connect and select My apps. Then, on the Project Setting page, set SHA-256 certificate fingerprint to the SHA-256 fingerprint from Configuring the Signing Certificate Fingerprint.

  • In AppGallery Connect, on My projects page, in Manage APIs tab, find and activate In App Purchases, then on My projects page, find In-App Purchases and set required settings. For more information, please refer to Setting In-App Purchases Parameters.

  • In AppGallery Connect, on My apps page, find your app from the list and click the app name. Go to Development > Overview > App Information. Click agconnect-service.json to download configuration file.

  • Finally, copy the agconnect-service.json file to the android/app directory of the demo project.

  • Package name must match with the package_name entry in agconnect-services.json file.

defaultConfig {
    applicationId "<package_name>"
    minSdkVersion 19 //minSdkVersion to 19 or higher.
    /*
     * <Other configurations>
     */
}
  • Do not forget to copy the signature file generated in Generating a Signing Certificate to android/app directory.

    Configure the signature in android according to the signature file information.

android {
    /*
     * <Other configurations>
     */

    signingConfigs {
        config {
            storeFile file('<keystore_file>.jks')
            storePassword '<keystore_password>'
            keyAlias '<key_alias>'
            keyPassword '<key_password>'
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.config
        }
        release {
            signingConfig signingConfigs.config
        }
    }
}
  • Go to your project's direction and open a terminal here, run your app with the following.
react-native run-android

3. HUAWEI Account Plugin for React Native

3.1 HmsAccountModule

3.1.1 Public Method Summary

MethodReturn Type
signIn(signInData)Promise <AuthHuaweiId>
signOut()Promise <Void>
silentSignIn()Promise <AuthHuaweiId>
cancelAuthorization()Promise <Void>

3.1.2 Public Methods

signIn(signInData)

Use this method to sign in.

signOut()

Use this method to sign out.

silentSignIn()

Use this method to silent sign in. Thus, the user won't need to enter the login credentials for the subsequent sign ins.

cancelAuthorization()

Use this method to cancel authorization. By calling this, the user will need to be authorized for subsequent sign ins.

3.2 AuthHuaweiIdModule

3.2.1 Public Methods Summary

MethodReturn Type
createDefault()Promise <AuthHuaweiId>
build(AuthHuaweiId)Promise <AuthHuaweiId>
getRequestedScopes(AuthHuaweiId)Promise <ScopeString>

3.2.2 Public Methods

createDefault()

Returns a default AuthHuaweiId object.

build(AuthHuaweiId)

Builds an AuthHuaweiId object with the given parameters.

getRequestedScopes(AuthHuaweiId)

Returns the requested scopes of AuthHuaweiId object.

3.3 HuaweiIdAuthManagerModule

3.3.1 Public Methods Summary

MethodReturn Type
getAuthResult()Promise <AuthHuaweiId>
getAuthResultWithScopes(Array <ScopeString>)Promise <AuthHuaweiId>
addAuthScopes(AddAuthScopesAndRequestCode)Void
containScopes(AuthHuaweiId)Promise <Boolean>

3.3.2 Public Methods

3.4 HuaweiIdAuthToolModule

3.4.1 Public Method Summary

MethodReturn Type
deleteAuthInfo(AccessToken)Promise
requestUnionId(HuaweiAccountName)Promise
requestAccessToken(AuthHuaweiId)Promise <Boolean>

3.4.2 Public Methods

deleteAuthInfo(AccessToken)

Clears the local cache.

requestUnionId(HuaweiAccountName)

Returns a union Id.

requestAccessToken(AuthHuaweiId)

Returns a token.

3.5 NetworkToolModule

3.5.1 Public Method Summary

MethodReturn Type
buildNetWorkCookie(CookieData)Promise <String>
buildNetworkUrl(UrlData)Promise <String>

3.5.2 Public Methods

buildNetWorkCookie(CookieData)

Constructs a cookie by combining input values.

buildNetworkUrl(UrlData)

Returns cookie url based on the domain name and isUseHttps.

3.6 SMSManagerModule

3.6.1 Public Method Summary

MethodReturn Type
startReadSMSManager()Promise
getHashCode()Promise <String>

3.6.2 Public Methods

startReadSMSManager()

Use this method to start readSMSManager. Which listens for verification the SMS broadcasts.

getHashCode()

Use this method to obtain a Hashcode. The hash code is added at the end of the verification SMS.

3.7 Objects

ObjectDescription
AccessTokenAccess token as a String
AddAuthScopesAndRequestCodeA map encapsulating a scope list and a request code
AuthHuaweiIdA map containing Huawei ID data
CookieDataA map containing the cookie data to be built
HuaweiAccountNameA String indicating the name of Huawei Account
ScopeStringName of a scope as a String
SignInDataA map containing the data to be used for signing in
UrlDataA map containing the data of URL to be built

3.8 Constants

ConstantDescription
CONSTANT_HUAWEI_ID_AUTH_PARAMS_DEFAULT_AUTH_REQUEST_PARAMExposes HuaweiIdAuthParam.DEFAULT_AUTH_REQUEST_PARAM
CONSTANT_HUAWEI_ID_AUTH_PARAMS_DEFAULT_AUTH_REQUEST_PARAM_GAMEExposes HuaweiIdAuthParam.DEFAULT_AUTH_REQUEST_PARAM_GAME
CONSTANT_READ_SMS_CONSTANT_EXTRA_SMS_MESSAGEExposes ReadSmsConstant.EXTRA_SMS_MESSAGE
CONSTANT_READ_SMS_CONSTANT_EXTRA_STATUSExposes ReadSmsConstant.EXTRA_STATUS
CONSTANT_READ_SMS_BROADCAST_ACTIONExposes ReadSmsConstant.READ_SMS_BROADCAST_ACTION
CONSTANT_HUAWEI_ID_AUTH_BUTTON_COLOR_POLICY_BLUEExposes HuaweiIdAuthButton.COLOR_POLICY_BLUE
CONSTANT_HUAWEI_ID_AUTH_BUTTON_COLOR_POLICY_REDExposes HuaweiIdAuthButton.COLOR_POLICY_RED
CONSTANT_HUAWEI_ID_AUTH_BUTTON_COLOR_POLICY_WHITEExposes HuaweiIdAuthButton.COLOR_POLICY_WHITE
CONSTANT_HUAWEI_ID_AUTH_BUTTON_COLOR_POLICY_WHITE_WITH_BORDERExposes HuaweiIdAuthButton.COLOR_POLICY_WHITE_WITH_BORDER
CONSTANT_HUAWEI_ID_AUTH_BUTTON_COLOR_POLICY_BLACKExposes HuaweiIdAuthButton.COLOR_POLICY_POLICY_BLACK
CONSTANT_HUAWEI_ID_AUTH_BUTTON_COLOR_POLICY_GRAYExposes HuaweiIdAuthButton.COLOR_POLICY_GRAY
CONSTANT_HUAWEI_ID_AUTH_BUTTON_THEME_FULL_TITLEExposes HuaweiIdAuthButton.THEME_FULL_TITLE
CONSTANT_HUAWEI_ID_AUTH_BUTTON_CORNER_RADIUS_LARGEExposes HuaweiIdAuthButton.CORNER_RADIUS_LARGE
CONSTANT_HUAWEI_ID_AUTH_BUTTON_CORNER_RADIUS_MEDIUMExposes HuaweiIdAuthButton.CORNER_RADIUS_MEDIUM
CONSTANT_HUAWEI_ID_AUTH_BUTTON_CORNER_RADIUS_SMALLExposes HuaweiIdAuthButton.CORNER_RADIUS_SMALL
SCOPE_ID_TOKENExposes the scope setIdToken
SCOPE_IDExposes the scope setId
SCOPE_ACCESS_TOKENExposes the scope setAccessToken
SCOPE_AUTHORIZATION_CODEExposes the scope setAuthorizationCode
SCOPE_EMAILExposes the scope setEmail
SCOPE_MOBILE_NUMBERExposes the scope setMobileNumber
SCOPE_PROFILEExposes the scope setProfile
SCOPE_SCOPE_LISTExposes the scope setScopeList
SCOPE_SHIPPING_ADDRESSExposes the scope setShippingAdress
SCOPE_UIDExposes the scope setUID
SCOPE_CREATE_PARAMSExposes the scope createParams

4. Configure parameters.

No.

5. Licensing and Terms

Huawei Reactive-Native SDK uses the Apache 2.0 license.