HMS Identity Kit |Address Management and Address Selection

Simge Keser
Huawei Developers
Published in
4 min readSep 11, 2020

Hello everyone, I have prepared an article for you about HUAWEI Identity Kit. I will explain step by step how to integrate the Identity kit into our applications. You will see how easy it is to use identity kit at the end. Let’s start by getting to know the Identity kit.

HUAWEI Identity Kit provides address management services for users, including adding, editing, deleting, and querying addresses, and enables the users to grant the permission for apps to access their addresses through a single tap on the screen.

Why should we use the Identity Kit?

When your app needs to use the user’s address including name, contact and detailed address, for example to deliver, it calls the HUAWEI Identity Kit API, prompts the user to select an address, and retrieves the selected address.

There are 3 main services provided by HUAWEI Identity Kit.

Address Management : allows users to enter, edit and search addresses
Address Access : Increases address management efficiency by allowing your app to reference user addresses directly after the user gets permission.
Address Selection : allows users to conveniently set and select the address.

Important Notes:

  • If a user tries to use functions provided by the HUAWEI Identity Kit without logging in using HUAWEI ID, Identity Kit displays the HUAWEI ID registration or sign-in page first. The user can use the functions provided by HUAWEI Identity Kit only after signing in using a registered HUAWEI ID.
  • A maximum of 10 user addresses are allowed.
  • You don’t need to integrate account kit however, your app users need to sign in to HMS Core (APK) with their HUAWEI ID before they can use the functions provided by HUAWEI Identity Kit.

Service Advantages

  • Easy access: 1 interface to integrate address selection service.
  • Extensive coverage : 170+ countries and regions.
  • Privacy protection : Strict compliance with European GDPR regulations and compliant use of address data.

Supported Locations

You can see the supported locations in the table below.

Software Requirements

  • Android Studio (3.0 or later)
  • Java SDK (1.7 or later)
  • HMS Core (APK) (4.0.0.300 or later)
  • HMS Core SDK (4.0.0.300 or later)

Implementation

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.

Integration HMS Core Sdk

After that, follow the steps in the link below to integrate HMS Core Sdk into the project and for more details about creating a new project on AppGallery Connect .

Add the Identity Kit to Project

You need to add the Identity Kit sdk to build.gradle in the app directory from Android Studio.

implementation 'com.huawei.hms:identity:4.0.4.300'.

Don’t forget => On the Project Setting page, click agconnect-services.json to download the configuration file and copy the agconnect-services.json file to the app directory.

Now,we have completed the necessary preparations to use the Identity Kit . Let’s see how to use the functions.

Obtaining a User Address

This API is used to display the address selection page when your app needs to use the user’s address-related information, such as name, contact, and detailed address. After the user selects an address on the page, it returns the address to the app.

getUserAddress(UserAddressRequest request): API request an address from a user. This will invoke an activity that allows the user to decide if they want to select a single address to share your app, or alternatively decline to share an address at all. In response, Identity kit will return success or failure result. If result is success , the startActivityForResult() method is called and the address selection page is displayed.

After the user selects an address, call the parseIntent method of UserAddress in onActivityResult of the page to obtain the address from the returned result.

Now, you integrated identity kit into your app. As you can see, it is quite easy to integrate HMS Identity kit :) Please, let me know if you have any questions :)

RESOURCES

--

--