Huawei Account Kit Flutter Plugin


Contents


1. Introduction

Flutter Account Kit Plugin enables communication between Huawei Account SDK and Flutter platform. It enables user login processes to be carried out quickly and easily with HUAWEI Account Kit's two factor authentication. Detailed information about the API's which are provided by this plugin can be found below.

  • HmsAuthService: Provides a set of API's that allows you to sign in to an app with a HUAWEI ID.
  • HmsAuthManager: Contains API's that are entry points for the HUAWEI ID sign-in service.
  • HmsAuthTool: Provides API's to obtain and delete authorization information.
  • HmsNetworkTool: Allows you to construct a cookie based on specified parameters.
  • HmsSmsManager: Enables the service of reading SMS messages until the SMS messages that meet the rules are obtained or the service times out (the timeout duration is 5 minutes).

This plugin enables communication between HUAWEI Account Kit SDK and Flutter platform. It exposes all functionality provided by HUAWEI Account Kit SDK.


2. Installation Guide

  • Before you get started, you must register as a HUAWEI developer and complete identity verification on the HUAWEI Developer website. For details, please refer to Register a HUAWEI ID.

  • Create an app in your project is required in AppGallery Connect in order to communicate with Huawei services. To create an app, perform the following steps:

Step 1. Sign in to AppGallery Connect and select My projects.

Step 2. Click your project from the project list.

Step 3. Go to Project Setting > General information, and click Add app. If an app exists in the project, and you need to add a new one, expand the app selection area on the top of the page and click Add app.

Step 4. On the Add app page, enter app information, and click OK.

  • A signing certificate fingerprint is used to verify the authenticity of an app when it attempts to access an HMS Core service through the HMS Core SDK. Before using HMS Core (APK), you must locally generate a signing certificate fingerprint and configure it in AppGallery Connect. Ensure that the JDK has been installed on your computer.

  • To use HUAWEI Account, you need to enable the Account service. For details, please refer to Enabling Services.

Configuring the Signing Certificate Fingerprint

Step 1: Go to Project Setting > General information. In the App information field, click the icon next to SHA-256 certificate fingerprint, and enter the obtained SHA256 certificate fingerprint.

Step 2: After completing the configuration, click check mark.

Integrating Flutter Account Plugin

Step 1: Sign in to AppGallery Connect and select My projects.

Step 2: Find your app project, and click the desired app name.

Step 3: Go to Project Setting > General information. In the App information section, click agconnect-service.json to download the configuration file.

Step 4: Create a Flutter project if you do not have one.

Step 5: Copy the agconnect-service.json file to the android/app directory of your Flutter project.

Step 6: Copy the signature file that generated in Generating a Signing Certificate section, to the android/app directory of your Flutter project.

Step 7: Check whether the agconnect-services.json file and signature file are successfully added to the android/app directory of the Flutter project.

Step 8: Open the build.gradle file in the android directory of your Flutter project.

  • Go to buildscript then configure the Maven repository address and agconnect plugin for the HMS SDK.

        buildscript {
            repositories {
                google()
                jcenter()
                maven { url 'https://developer.huawei.com/repo/' }
            }
    
            dependencies {
                /*
                 * <Other dependencies>
                 */
                classpath 'com.huawei.agconnect:agcp:1.4.1.300'
            }
        }
    
  • Go to allprojects then configure the Maven repository address for the HMS SDK.

        allprojects {
            repositories {
                google()
                jcenter()
                maven { url 'https://developer.huawei.com/repo/' }
            }
        }
    

Step 9: Open the build.gradle file in the android/app directory.

  • Add apply plugin: 'com.huawei.agconnect' line after the apply entries.

        apply plugin: 'com.android.application'
        apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
        apply plugin: 'com.huawei.agconnect'
    
  • Set your package name in defaultConfig > applicationId and set minSdkVersion to 19 or higher.

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

        defaultConfig {
                applicationId "<package_name>"
                minSdkVersion 19
                /*
                 * <Other configurations>
                 */
            }
    
  • Copy the signature file that generated in Generating a Signing Certificate to android/app directory.

  • Configure the signature in android according to the signature file information and configure Obfuscation Scripts.

        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 {
                    minifyEnabled true
                    shrinkResources true
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                    signingConfig signingConfigs.config
                }
            }
        }
    
  • For Obfuscation Scripts, please refer to Configuring Obfuscation Scripts.

Step 10: On your Flutter project directory find and open your pubspec.yaml file and add library to dependencies.

  • To download the package from pub.dev.

    dependencies:
      huawei_account: { library version }
    

    or

    If you downloaded the package from the HUAWEI Developer website, specify the library path on your local device.

    dependencies:
      huawei_account:
        # Replace {library path} with actual library path of Huawei Account Plugin for Flutter.
        path: { library path }
    
    • Replace {library path} with the actual library path of Flutter Account Plugin. The following are examples:
      • Relative path example: path: ../huawei_account
      • Absolute path example: path: D:\Projects\Libraries\huawei_account

Step 11: Run following command to update package info.

  [project_path]> flutter pub get

Step 12: Run following command to start the app.

  [project_path]> flutter run

3. API Reference

HmsAuthService

Public Method Summary

MethodReturn TypeDescription
signIn(HmsAuthParamHelper helper)Future<HmsAuthHuaweiId>Obtains the intent of the HUAWEI ID sign-in authorization page.
silentSignIn(HmsAuthParamHelper helper)Future<HmsAuthHuaweiId>Obtains the sign-in information (or error information) about the HUAWEI ID that has been used to sign in to the app
signOut()Future<bool>Signs out of the HUAWEI ID.
revokeAuthorization()Future<bool>Cancels the authorization from the HUAWEI ID user.
enableLogger()Future<void>Enables HMS Plugin Method Analytics.
disableLogger()Future<void>Disables HMS Plugin Method Analytics.

Public Methods

Future<HmsAuthHuaweiId> signIn({HmsAuthParamHelper helper}) async

This method is used to obtain the intent of the HUAWEI ID sign-in authorization page. When this method is called, an authorization page shows up. After signing in, the HUAWEI ID information is obtained via HmsAuthHuaweiId object.

Parameters
ParameterDescription
helperCustomizes the signing request.
Return
TypeDescription
Future<HmsAuthHuaweiId>Returns the HmsAuthHuaweiId object on a successful operation, throws Exception otherwise.
Call Example
// Create an instance of HmsAuthParamHelper
final helper = new HmsAuthParamHelper();

// Request user to authorize the app to obtain idToken and accessToken
helper..setIdToken()..setAccessToken();

try {
  // The parameter is optional You can call the method directly.
  final HmsAuthHuaweiId id = await HmsAuthService.signIn(authParamHelper: helper);
} on Exception catch(e) {
  print(e.toString());
}
Future<HmsAuthHuaweiId> silentSignIn({HmsAuthParamHelper helper}) async

This method is used to obtain the HUAWEI ID that has been used to sign in to the app. In this process, the authorization page is not displayed to the HUAWEI ID user.

Parameters
ParameterDescription
helperCustomizes the signing request.
Return
TypeDescription
Future<HmsAuthHuaweiId>Returns the HmsAuthHuaweiId object on a successful operation, throws Exception otherwise.
Call Example
final helper = new HmsAuthParamHelper();

helper..setIdToken()..setAccessToken();

try {
  final HmsAuthHuaweiId id = await HmsAuthService.silentSignIn(authParamHelper: helper);
} on Exception catch(e) {
  print(e.toString());
}
Future<bool> signOut() async

This method is used to sign out a HUAWEI ID. The HMS Core Account SDK deletes the cached HUAWEI ID information.

Return
TypeDescription
Future<bool>Returns true on a successful operation, throws Exception otherwise.
Call Example
try {
  final bool res = await HmsAuthService.signOut();
} on Exception catch(e) {
  print(e.toString());
}
Future<bool> revokeAuthorization() async

This method is used to cancel the authorization from the HUAWEI ID user. All user data will be removed after this method. On another signing attempt, the authorization page will be shown.

Return
TypeDescription
Future<bool>Returns true on a successful operation, throws Exception otherwise.
Call Example
try {
  final bool res = await HmsAuthService.revokeAuthorization();
} on Exception catch(e) {
  print(e.toString());
}
Future<void> enableLogger()

This method is used to enable HMS Plugin Method Analytics.

Return
TypeDescription
Future<void>This method does not return anything.
Call Example
HmsAuthService.enableLogger();
Future<void> disableLogger()

This method is used to disable HMS Plugin Method Analytics.

Return
TypeDescription
Future<void>This method does not return anything.
Call Example
HmsAuthService.disableLogger();

HmsAuthManager

Public Method Summary

MethodReturn TypeDescription
getAuthResult()Future<HmsAuthHuaweiId>Obtains the information about the HUAWEI ID in the latest sign-in.
getAuthResultWithScopes(List<String> scopeList)Future<HmsAuthHuaweiId>Obtains an HmsAuthHuaweiId instance.
addAuthScopes(int requestCode, List<String> scopeList)Future<bool>Requests the permission specified by scopeList from a HUAWEI ID.
containScopes(HmsAuthHuaweiId authHuaweiId, List<String> scopeList)Future<bool>Checks whether a specified HUAWEI ID has been assigned all permission specified by scopeList.

Public Methods

Future<HmsAuthHuaweiId> getAuthResult() async

This method is used to obtain the information about the HUAWEI ID in the latest sign-in.

Return
TypeDescription
Future<HmsAuthHuaweiId>Returns the HUAWEI ID information if there's a signing in attempt before
Call Example
final HmsAuthHuaweiId id = await HmsAuthManager.getAuthResult();
Future<HmsAuthHuaweiId> getAuthResultWithScopes(List<String> scopeList) async

This method is used to obtain an HmsAuthHuaweiId instance.

Parameters
ParameterDescription
scopeListScope values.
Return
TypeDescription
Future<HmsAuthHuaweiId>Returns the HUAWEI ID information on a successful operation, throws Exception otherwise.
Call Example
try {
  final HmsAuthHuaweiId id =
    await HmsAuthManager.getAuthResultWithScopes([HmsScope.email]);
} on Exception catch(e) {
  print(e.toString());
}
Future<bool> addAuthScopes(int requestCode, List<String> scopeList) async

This method requests the permission specified by scopeList from a HUAWEI ID.

Parameters
ParameterDescription
requestCodeRequest code that will be used while adding auth scopes.
scopeListScope list.
Return
TypeDescription
Future<bool>Returns true on a successful operation, throws Exception otherwise.
Call Example
try {
  final bool res = await HmsAuthManager.addAuthScopes(
    // Specify a request code
    requestCode: 8888,
    // Then specify desired scopes
    scopeList: [HmsScope.email]
  );
} on Exception catch(e) {
  print(e.toString());
}
Future<bool> containScopes(HmsAuthHuaweiId authHuaweiId, List<String> scopeList) async

This method checks whether a specified HUAWEI ID has been assigned all permission specified by scopeList.

Parameters
ParameterDescription
authHuaweiIdSigned HUAWEI ID information.
scopeListScope list.
Return
TypeDescription
Future<bool>Returns true on a successful operation, throws Exception otherwise.
Call Example
try {
  final bool res = await HmsAuthManager.containScopes(
    // Specify the ID that is returned from signing in
    authHuaweiId: _signInResult,
    // Check if the email permission is requested from the HUAWEI ID
    scopeList: [HmsScope.email]
  )
} on Exception catch(e) {
  print(e.toString());
}

HmsAuthTool

Public Method Summary

MethodReturn TypeDescription
requestUnionId(HmsAccount account)Future<String>Obtains a union id.
requestAccessToken(HmsAccount account, List<String> scopeList)Future<String>Obtains an access token.
deleteAuthInfo(String accessToken)Future<bool>Clears the local cache.

Public Methods

Future<String> requestUnionId(HmsAccount account) async

This method is used to obtain a union id.

Parameters
ParameterDescription
accountAccount information obtained from signed HUAWEI ID
Return
TypeDescription
Future<String>Returns the union id on a successful operation, throws Exception otherwise.
Call Example
try {
  // Specify the HmsAccount object obtained from signing in.
  final String unionId = await HmsAuthTool.requestUnionId(account: _accountInfo);
} on Exception catch(e) {
  print(e.toString());
}
Future<String> requestAccessToken(HmsAccount, List<String> scopeList) async

This method is used to obtain an access token.

Parameters
ParameterDescription
accountAccount information obtained from signed HUAWEI ID
scopeListScope list
Return
TypeDescription
Future<String>Returns the access token on a successful operation, throws Exception otherwise.
Call Example
try {
  final String accessToken = await HmsAuthTool.requestAccessToken(
    account: _accountInfo,
    scopeList: [HmsScope.email]
  );
}
Future<bool> deleteAuthInfo(String accessToken) async

This method is used to clear the local cache.

Parameters
ParameterDescription
accessTokenAccess token obtained from signed HUAWEI ID
Return
TypeDescription
Future<bool>Returns true on a successful operation, throws exception otherwise.
Call Example
try {
  // Specify the access token obtained from signed HUAWEI ID
  final bool res = await HmsAuthTool.deleteAuthInfo(accessToken: _accessToken);
} on Exception catch(e) {
  print(e.toString());
}

HmsNetworkTool

Public Method Summary

MethodReturn TypeDescription
buildNetworkCookie(String cookieName, String cookieValue, String domain, String path, bool isHttpOnly, bool isSecure, double maxAge)Future<String>Constructs a cookie by combining entered values.
buildNetworkUrl(String domain, bool isUseHttps)Future<String>Obtains a cookie URL based on the domain name and isUseHttps.

Public Methods

Future<String> buildNetworkCookie(String cookieName, String cookieValue, String domain, String path, bool isHttpOnly, bool isSecure, double maxAge) async

This method is used to construct a cookie by combining entered values.

Parameters
ParameterDescription
cookieNameCookie name.
cookieValueCookie value.
domainCookie domain name.
pathPage URL for accessing the cookie.
isHttpOnlyIndicates whether cookie information is contained only in the HTTP request header and cannot be accessed through document.cookie. The options are true and false.
isSecureIndicates whether to use HTTPS or HTTP to transmit the cookie.
maxAgeCookie lifetime, in seconds.
Return
TypeDescription
Future<String>Returns the cookie value on a successful operation, throws Exception otherwise.
Call Example
try {
  final String cookie = await HmsNetworkTool.buildNetworkCookie(
    cookieName: "cookie name",
    cookieValue: "cookie value",
    domain: "domain",
    path: "path",
    isHttpOnly: false,
    isSecure: true,
    maxAge: 18000
  );
} on Exception catch(e) {
  print(e.toString());
}
Future<String> buildNetworkUrl(String domain, bool isUseHttps) async

This method is used to obtain a cookie URL based on the domain name and isUseHttps.

Parameters
ParameterDescription
domainDomain name.
isUseHttpsIndicates whether to use HTTPS or HTTP. The options are as follows: true: HTTPS; false: HTTP
Return
TypeDescription
Future<String>Returns the URL on a successful operation, throws Exception otherwise.
Call Example
try {
  final String url = await HmsNetworkTool.buildNetworkUrl(
    domain: "domain name",
    isUseHttps: true
  );
}

HmsSmsManager

Public Method Summary

MethodReturn TypeDescription
smsVerification(SmsListener listener)Future<void>Starts listening upcoming sms messages to the app before timing out.
obtainHashcode()Future<String>Obtains the application's unique hashcode value.

Public Methods

Future<void> smsVerification(SmsListener listener) async

This method starts listening upcoming sms messages to the app which contain the app's unique hashcode value. The SmsListener delivers the message itself on success or an error code on time out.

Parameters
ParameterDescription
SmsListenerResponses to the sms manager api and returns the message or an error code depending on the situation.
Return
TypeDescription
Future<void>This method only starts listening sms messages. Does not return a value.
Call Example
HmsSmsManager.smsVerification(({errorCode, message}) {
  if (message != null) {
    // Use the message
  } else {
    print("Error code: $errorCode");
  }
});
Future<String> obtainHashcode() async

This method is used to obtain application's unique hashcode value. If you want to use sms verification service, you need to specify this hashcode in the message. Otherwise the service can not recognize the message.

Return
TypeDescription
Future<String>Returns the hashcode value on a successful operation, throws Exception otherwise.
Call Example
try {
  final String hashcode = await HmsSmsManager.obtainHashcode();
} on Exception catch(e) {
  print(e.toString());
}

Data Types

Data Types Summary

TypeDescription
SmsListenerDuring the sms verification, returns the message or an error code depending on the sutiation.
HmsAuthParamHelperContains properties and methods to customize the signing requests.
HmsAuthParamsContains default authorization parameters for signing requests.
HmsScopeContains constant scope values.
HmsAccountContains account informaiton obtained from signed HUAWEI ID.
HmsAuthHuaweiIdContains signed HUAWEI ID information.
HmsAuthButtonA special button for the HUAWEI Account Flutter Plugin.
HmsAccountErrorCodesContains specific error codes for the plugin methods.

HmsAuthParamHelper

Public Method Summary
MethodReturn TypeDescription
setDefaultParam(int param)voidSets the default authorization parameter of a HUAWEI ID. 0 indicates the default authorization param of a HUAWEI ID. 1 indicates the default authorization parameter of a game.
setIdToken()voidRequests a HUAWEI ID user to authorize an app to obtain the ID token.
setProfile()voidRequests a HUAWEI ID user to authorize an app to obtain the account information, such as the nickname and profile picture.
setAccessToken()voidRequests a HUAWEI ID user to authorize an app to obtain the access token.
setAuthorizationCode()voidRequests a HUAWEI ID user to authorize an app to obtain the authorization code. If this is used, you do not need to call setIdToken(). When your app server uses the authorization code to exchange a token with the HUAWEI ID OAuth server, the ID token will be returned in the result.
setEmail()voidRequests a HUAWEI ID user to authorize an app to obtain the email address.
setId()voidRequests a HUAWEI ID user to authorize an app to obtain the UnionID.
setScopeList(List<String> scopes)voidAdds a specified scope to authorization configurations to request a HUAWEI ID user to authorize an app to obtain the permission specified by scope.
setRequestCode(int requestCode)voidSets the request code which will be used while signing in.
Public Methods

Instead of calling the methods one by one, you can call any number of these methods simultaneously using cascades.

// Create an instance of HmsAuthParamHelper object

final helper = new HmsAuthParamHelper();

// Then, call its methods as follows
helper
  ..setIdToken()
  ..setAccessToken()
  ..setAuthorizationCode()
  ..setEmail()
  ..setProfile()
  ..setId()
Public Properties
NameTypeDescription
requestDataMap<String, dynamic>Contains default request configurations for signing in. Values are all customizable.

HmsAuthParams

Public Properties
NameTypeValueDescription
defaultAuthRequestParamint0Default authorization param of a HUAWEI ID.
defaultAuthRequestParamGameint1Default authorization parameter of a game.

HmsScope

Public Properties
NameTypeValueDescription
emailStringemailEmail address of a HUAWEI ID.
profileStringprofileBasic information of a HUAWEI ID, such as the profile picture and nickname.
openIdStringopenidOpenID of a HUAWEI ID.
gameStringhttps://www.huawei.com/auth/gamesSpecial scope of games.

HmsAccount

Public Properties
NameTypeDescription
nameStringName of the account
typeStringType of the account
Public Constructor Summary
ConstructorDescription
HmsAccount({String name, String type})Default constructor
Public Constructors
HmsAccount({String name, String type})

Constructs for HmsAccount object.

HmsAuthHuaweiId

Public Properties
NameTypeDescription
accessTokenStringObtains the access token from HUAWEI ID information.
accountHmsAccountObtains an android.accounts. Account object based on the email address that is obtained by HUAWEI ID.
displayNameStringObtains the nickname from HUAWEI ID information if the authorization parameter specified by HmsAuthParams.defaultAuthRequestParam or setProfile() is carried during authorization. Otherwise the value is null.
emailStringObtains the email address from HUAWEI ID information if setEmail() is carried during authorization. Otherwise the value is null.
familyNameStringObtains the family name from HUAWEI ID information if the authorization parameter specified by HmsAuthParams.defaultAuthRequestParam or setProfile() is carried during authorization. Otherwise the value is null.
givenNameStringObtains the given name from HUAWEI ID information if the authorization parameter specified by HmsAuthParams.defaultAuthRequestParam or setProfile() is carried during authorization. Otherwise the value is null.
authorizedScopesList<dynamic>Obtains the authorized scopes in HmsScope from HUAWEI ID information.
idTokenStringObtains the ID token from HUAWEI ID information if the authorization parameter specified by setIdToken() is carried during authorization. Otherwise the value is null.
avatarUriStringStringObtains the profile picture URI from HUAWEI ID information if the authorization parameter specified by HmsAuthParams.defaultAuthRequestParam or setProfile() is carried during authorization. Otherwise the value is null.
authorizationCodeStringObtains the authorization code from HUAWEI ID information. If no authorization code is carried, value null is returned. The app can use the authorization code to obtain the access token from the HUAWEI ID server.
unionIdStringObtains the UnionID from HUAWEI ID information if the authorization parameter specified by setId() is carried during the authorization. Otherwise the value is null.
openIdStringObtains the OpenID from HUAWEI ID information if the authorization parameter specified by setId() is carried during the authorization. Otherwise the value is null.
Public Constructor Summary
ConstructorDescription
HmsAuthHuaweiId({String accessToken, HmsAccount account, String displayName, String email, String familyName, String givenName, List<dynamic> authorizedScopes, String idToken, String avatarUriString, String authorizationCode, String unionId, String openId})Default constructor
Public Constructors
HmsAuthHuaweiId({String accessToken, HmsAccount account, String displayName, String email, String familyName, String givenName, List<dynamic> authorizedScopes, String idToken, String avatarUriString, String authorizationCode, String unionId, String openId})

Constructs for HmsAuthHuaweiId object.

Public Method Summary
MethodReturn TypeDescription
createDefault()HmsAuthHuaweiIdCreates an instance with null parameters.
Public Methods
HmsAuthHuaweiId createDefault()

This method is used to create an instance of HmsAuthHuaweiId object with null parameters.

Return
TypeDescription
HmsAuthHuaweiIdDefault instance.
Call Example
final HmsAuthHuaweiId id = HmsAuthHuaweiId().createDefault();

SmsListener

typedef void SmsListener

Listener for upcoming messages to the application.

Definition
SmsListener({String message, String errorCode})

This is a function type defined to listen and return upcoming messages to the application. On a successful sms verification, this listener returns the received message. Otherwise, on time out for example, it returns the error code.

Parameters
ParameterDescription
messageSuccessfuly received message.
errorCodeObtained error code.

HmsAuthButton

Public Properties
NameTypeDescription
AuthButtonThemeenumFULL_TITLE indicates that button has a logo and a title, NO_TITLE represents that button has only a logo.
AuthButtonBackgroundenumSets the button color. Color options are BLUE, BLACK, GREY, RED and WHITE.
AuthButtonRadiusenumProperty to set button's corner radius. The options are SMALL, MEDIUM and LARGE.
onPressedVoidCallbackRequired parameter to specify an action when button is pressed.
widthdoubleSets the button width.
paddingdoubleSets the button padding.
textColorColorSets the button text color.
fontSizedoubleSets the size of button text.
fontWeightFontWeightSets the font weight of button text.
Public Constructor Summary
ConstructorDescription
HmsAuthButton({Key key, @required VoidCallback onPressed, double width, AuthButtonRadius borderRadius, AuthButtonBackground buttonColor, FontWeight fontWeight, double fontSize, Color textColor, AuthButtonTheme theme, double padding})Default constructor
Public Constructors
HmsAuthButton({Key key, @required VoidCallback onPressed, double width, AuthButtonRadius borderRadius, AuthButtonBackground buttonColor, FontWeight fontWeight, double fontSize, Color textColor, AuthButtonTheme theme, double padding})

Constructs for HmsAuthButton object.

HmsAccountErrorCodes

Public Properties
NameTypeValueDescription
NULL_AUTH_SERVICEString0001When a method that requires an authorization done before is triggered, this error is shown in exception
ILLEGAL_PARAMETERString0002This code is shown in exception when some required parameters are missing
GET_AUTH_RESULT_WITH_SCOPES_FAILUREString100Indicates that the problem was originated from getAuthResultWithScopes() method.
ADD_AUTH_SCOPES_FAILUREString101Indicates that the problem was originated from addAuthScopes() method.
CONTAIN_SCOPES_FAILUREString102Indicates that the problem was originated from containScopes() method.
SIGN_IN_FAILUREString103Indicates that the problem was originated from signIn() method.
SILENT_SIGN_IN_FAILUREString104Indicates that the problem was originated from silentSignIn() method.
SIGN_OUT_FAILUREString105Indicates that the problem was originated from signOut() method.
REVOKE_AUTHORIZATION_FAILUREString106Indicates that the problem was originated from revokeAuthorization() method.
REQUEST_UNION_ID_FAILUREString107Indicates that the problem was originated from requestUnionId() method.
REQUEST_ACCESS_TOKEN_FAILUREString108Indicates that the problem was originated from requestAccessToken() method.
DELETE_AUTH_INFO_FAILUREString109Indicates that the problem was originated from deleteAuthInfo() method.
BUILD_NETWORK_COOKIE_FAILUREString110Indicates that the problem was originated from buildNetworkCookie() method.
BUILD_NETWORK_URL_FAILUREString111Indicates that the problem was originated from buildNetworkUrl() method.
SMS_VERIFICATION_FAILUREString112Indicates that the problem was originated from smsVerification() method.
OBTAIN_HASHCODE_VALUE_FAILUREString113Indicates that the problem was originated from obtainHashcode() method.
SMS_VERIFICATION_TIME_OUTString114Indicates that the sms verification process failed because of time out.

4. Configuration and Description

Preparing for Release

Before building a release version of your app you may need to customize the proguard-rules.pro obfuscation configuration file to prevent the HMS Core SDK from being obfuscated. Add the configurations below to exclude the HMS Core SDK from obfuscation. For more information on this topic refer to this Android developer guide.

<flutter_project>/android/app/proguard-rules.pro

-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.hms.flutter.** { *; }

# Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }
-dontwarn io.flutter.embedding.**
-repackageclasses

<flutter_project>/android/app/build.gradle

buildTypes {
    debug {
        signingConfig signingConfigs.config
    }
    release {
        signingConfig signingConfigs.config
        // Enables code shrinking, obfuscation and optimization for release builds
        minifyEnabled true
        // Unused resources will be removed, resources defined in the res/raw/keep.xml will be kept.
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

5. Sample Project

This plugin includes a demo project in the example folder, there you can find more usage examples.


6. Questions or Issues

If you have questions about how to use HMS samples, try the following options:

  • Stack Overflow is the best place for any programming questions. Be sure to tag your question with huawei-mobile-services.
  • Github is the official repository for these plugins, You can open an issue or submit your ideas.
  • Huawei Developer Forum HMS Core Module is great for general questions, or seeking recommendations and opinions.
  • Huawei Developer Docs is place to official documentation for all HMS Core Kits, you can find detailed documentations in there.

If you run into a bug in our samples, please submit an issue to the GitHub repository.


7. Licensing and Terms

Huawei Account Kit Flutter Plugin is licensed under Apache 2.0 license

Libraries

hms_account
hms_account_error_codes
hms_auth_button
hms_auth_huawei_id
hms_auth_manager
hms_auth_param_helper
hms_auth_params
hms_auth_service
hms_auth_tool
hms_network_tool
hms_scope
hms_sms_manager
huawei_account