[Huawei Developers] muraliameakula:
You may receive various requirements from product managers in daily work. Basically, you should have a general understanding of the requirement for questioning and reviewing the requirement when communicating further with the product manager. This article simply demonstrates why the third-party sign-in function worth to be integrated to an app.

What is third-party sign-in?

Third-party sign-in helps users register and sign in to an app after authorization with a registered account and password from a third-party platform.

Why does an app need to integrate the third-party sign-in function?

For users: When registering or signing in to an app, users often give up when they experience issues such as a verification code sending too slow or not being sent at all. Creating an app that features a seamless registration and sign-in experience is often overlooked.

For marketers: A lot of advertising is involved before a user even finds and installs an app, which is expensive both for apps that are in startup phase and in mature phase.

Third-party sign-in is a good choice for apps to retain users which ensures that users can smoothly register and sign in to an app.

What third-party sign-in modes are available?

Social third-party sign-in: applicable to most apps.

E-commerce third-party sign-in: suitable for apps in fields such as e-commerce, finance, and travel that involve abundant payment scenarios.

Are there any other third-party sign-in modes?

Similar to most third-party sign-in modes, HUAWEI Account Kit allows users to sign in to an app on multiple devices including Huawei phones, tablets, and HUAWEI Visions with their HUAWEI IDs.

​

HUAWEI Account Kit provides the following services:

1. Convenient app sign-in

Users can quickly and easily sign in to apps with their HUAWEI IDs. For first time set-up, users need to authorize the app in order to later sign in to the app with just one tap. For even greater convenience, one HUAWEI ID can be used to sign in to all apps.

​

2. Supported sign-in on multiple devices by scanning barcodes

All HMS apps and services can be used on Huawei devices by signing in with a HUAWEI ID. In addition, once a user signs in to the account center using a HUAWEI ID, the user's account information can be synchronized on all Huawei devices, enhancing user experience and convenience at the tap of a button.

​

3. Secure sign-in

HUAWEI Account Kit safeguards user accounts with two-factor authentication (password plus verification code).

​

How do I integrate HUAWEI Account Kit?

If you are using Android Studio, you can integrate the HMS Core SDK via the Maven repository. Before you start developing an app, integrate the HMS Core SDK into your Android Studio project.

Adding the AppGallery Connect configuration file of your app.

If you have enabled certain services in AppGallery Connect, add the agconnect-services.json file to your app.

Sign in to AppGallery Connect and click My projects.

Find your project and click the app for which you want to integrate the HMS Core SDK.

Go to Project settings > General information. In the App information area, download the agconnect-services.json file.

Copy the agconnect-services.json file to the app's root directory of your Android Studio project.

Configuring the Maven repository address for the HMS Core SDK.

Open the build.gradle file in the root directory of your Android Studio project.

Add the AppGallery Connect plugin and the Maven repository.

Go to buildscript > repositories and configure the Maven repository address for the HMS Core SDK.

Go to allprojects > repositories and configure the Maven repository address for the HMS Core SDK.

If the agconnect-services.json file has been added to the app, go to buildscript > dependencies and add the AppGallery Connect plugin configuration.

buildscript {
repositories {
google()
jcenter()
// Configure the Maven repository address for the HMS Core SDK.
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
...
// Add the AppGallery Connect plugin configuration.
classpath 'com.huawei.agconnect:agcp:1.4.2.300'
}
}

allprojects {
repositories {
google()
jcenter()
// Configure the Maven repository address for the HMS Core SDK.
maven {url 'https://developer.huawei.com/repo/'}
}
}

Note: The Maven repository address cannot be accessed from a browser. It can only be configured in the IDE. If there are multiple Maven repositories, add the Maven repository address of Huawei as the last one.

Adding build dependencies.

Open the build.gradle file in the app directory.

Add a build dependency in the dependencies block.

dependencies {
implementation 'com.huawei.hms:hwid:
{version}
'
}

Note: hwid indicates HUAWEI Account Kit. Replace {version} with the actual SDK version number, for example, implementation 'com.huawei.hms:hwid:5.2.0.300. For details about the version number, please refer to Version Change History.

Add the AppGallery Connect plugin configuration.

In versions earlier than Android Studio 4.0, add the following information under apply plugin: 'com.android.application' in the file header:

apply plugin: 'com.huawei.agconnect'

In Android Studio 4.0 or later, add the following configuration in the plugins block:

plugins {
...
id 'com.huawei.agconnect'
}

Defining multi-language settings.

By default, your app supports all languages provided by the HMS Core SDK. If your app uses all of these languages, skip this section.

If your app uses only some of these languages, follow the steps in this section to complete the required configuration.

Open the build.gradle file in the app directory.

Go to android > defaultConfig, add resConfigs, and configure the supported languages as follows:

android {
defaultConfig {
...
resConfigs "en", "zh-rCN", "Other languages supported by your app"
}
}

For details about the languages supported by the HMS Core SDK, please refer to Languages Supported by HMS Core SDK.

Synchronizing the project.

After completing the configuration, click the synchronization icon on the toolbar to synchronize the Gradle files.

Note: If an error occurs, check the network connection and the configuration in the Gradle files.

Configuring metadata.

Note:

In the following scenario, configure metadata to prompt users to download HMS Core (APK):

HUAWEI AppGallery allows your app to download other apps in the background, and you call relevant APIs through an activity.

In the following scenario, skip the configuration steps. Currently, it is not possible to prompt users to download HMS Core (APK).

In contrast, Google Play does not allow your app to download other apps in the background, or you call relevant APIs through a context.

Add the following code to the application element in the AndroidManifest.xml file to prompt users to download HMS Core (APK):

<application ...>
<meta-data
android:name="com.huawei.hms.client.channel.androidMarket"
android:value="false" />
...
</application>

After HMS Core (APK) is downloaded, the HMS Core SDK will automatically install or update HMS Core (APK).

Configuring the AndroidManifest.xml file.

Android 11 has changed the way an app queries and interacts with other apps on the device. You can use the <queries> element to define a group of apps that your app can access.

If targetSdkVersion is 30 or later, add the <queries> element in the manifest element in AndroidManifest.xml to grant you app access to HMS Core (APK).

<manifest ...>
...
<queries>
<intent>
<action android:name="com.huawei.hms.core.aidlservice" />
</intent>
</queries>
...
</manifest>

Note:

The <queries> element requires the following:

Your Android Studio version is 3.3 or later.

The Android Gradle plugin supported by your Android Studio is in the latest dot release. For more details, please visit the link.

To learn more, please visit:

HUAWEI Developers official website

Development Guide

Reddit to join developer discussions

GitHub or Gitee to download the demo and sample code

Stack Overflow to solve integration problems

Follow our official account for the latest HMS Core-related news and updates.

Original Source