Integration of User Address by Huawei Identity Kit in Android apps (Kotlin)
Introduction
In this article, we can learn the integration of user address in apps by Huawei Identity Kit. The Identity Kit provides an easy interface to add or edit or delete user details and enables the users to grant permission for apps to access their addresses through a single click on the screen.
This kit is mainly used in e-commerce, food delivery and logistics apps to deliver the products in an easy and safe way to users.
Services
- Address Management: Users can enter and edit address information.
- Address Access: Increases productivity by allowing user to access address information with the required permission from users.
- Address Selection: Users can select addresses quickly and reliably.
Advantages
- Easy access: Only one interface to integrate address selection service.
- Extensive coverage: More than 170 countries and regions are covered.
- Privacy protection: Strict compliance with European General Data Protection Regulation (GDPR) regulations and compliant use of address data.
Requirements
1. Any operating system (MacOS, Linux and Windows).
2. Must have a Huawei phone with HMS 4.0.0.300 or later.
3. Must have a laptop or desktop with Android Studio, Jdk 1.8, SDK platform 26 and Gradle 4.6 installed.
4. Minimum API Level 21 is required.
5. Required EMUI 9.0.0 and later version devices.
How to integrate HMS Dependencies
1. First register as Huawei developer and complete identity verification in Huawei developers website, refer to register a Huawei ID.
2. Create a project in android studio, refer Creating an Android Studio Project.
3. Generate a SHA-256 certificate fingerprint.
4. To generate SHA-256 certificate fingerprint. On right-upper corner of android project click Gradle, choose Project Name > Tasks > android, and then click signingReport, as follows.
Note: Project Name depends on the user created name.
5. Create an App in AppGallery Connect.
6. Download the agconnect-services.json file from App information, copy and paste in android Project under app directory, as follows.
7. Enter SHA-256 certificate fingerprint and click tick icon, as follows.
Note: Above steps from Step 1 to 7 is common for all Huawei Kits.
8. Add the below maven URL in build.gradle(Project) file under the repositories of buildscript, dependencies and allprojects, refer Add Configuration.
9. Add the below plugin and dependencies in build.gradle(Module) file.
10. Now Sync the gradle.
11. Add the required permission to the AndroidManifest.xml file.
Let us move to development
I have created a project on Android studio with empty activity let’s start coding.
In the MainActivity.kt we can create the business logic.
In the activity_main.xml we can create the UI screen.
Demo
Tips and Tricks
1. Make sure you are already registered as Huawei developer.
2. Set minSDK version to 21 or later.
3. Make sure you have added the agconnect-services.json file to app folder.
4. Make sure you have added SHA-256 fingerprint without fail.
5. Make sure all the dependencies are added properly.
6. The Identity Kit functions can be used only after signin with registered Huawei ID.
7. A maximum of 10 user addresses are allowed.
Conclusion
In this article, we have learnt integration of user address feature in apps by Huawei Identity Kit. It allows the user to login with Huawei ID and can access the easy interface to add or edit or delete user details. It helps to deliver the online booking products by e-commerce, food delivery and logistics apps in an easy and safe way to users.
I hope you have read this article. If you found it is helpful, please provide likes and comments.
Reference