05/15/2024 15:19:45

Description of HMS (Huawei Mobile Services) channel

I. Overview

HMS stands for Huawei Mobile Service.

In HMS, HUAWEI account provides developers with a simple and secure login authorization function, which can facilitate users to log in quickly. Without entering any account or password or having tedious verification, user can quickly log in through "Huawei Account Login" and immediately use the developer's app.

II. Developer platform configuration

The configuration process of Huawei Developer Platform is as follows:

1.Register as a developer

Before developing an application, you need to register as a developer and complete real-name authentication on Huawei Developer Alliance website. For the specific method, please refer to the account Account Registration Authentication.

2.Create an application

Refer to the Create Application chapter of the AppGallery Connect Help Center to create an application. The special configuration is as follows:

  • "Software Package Type": select "APK (Android Application)".
  • "Supported Device": select "Mobile Phone".
  • "Application Category": select "Application" or "Game".

3.Generate a signature certificate fingerprint

The signature certificate fingerprint is used to verify the authenticity of the app when the app calls HMS Core (APK) through Huawei HMS SDK. Developers must configure the signature certificate fingerprint to the Huawei Developer Alliance before using the HMS Core (APK). The signature certificate fingerprint must be generated locally based on the signature certificate before such configuration. The following two conditions must be met before a developer applies for such fingerprint:

  • The signature certificate of the application has been created. The creation of the signature certificate is general technology and will not be described in detail here.
  • The currently developed PC has installed JDK (JDK 1.8 and above).

    Then query the SHA256 fingerprint of the signature certificate through the following command:

    keytool -list -v -keystore <keystore-file>
    

4.Configure the signature certificate fingerprint

(1) Log into AppGallery Connect website to select "My App".

(2) Find the corresponding application product, and select and click the "Android Application" link to enter the application development page.

(3) In the "SHA256 Certificate Fingerprint" configuration column, enter SHA256 fingerprint generated in the Generate Signature Certificate Fingerprint chapter.

(4) After the configuration is completed, click the nearby tick button.

5.Turn on the HuaweiAccount service switch for the app according to the Enable Service document

6.Download the latest agconnect-services.json configuration file for backup

III. Project configuration

3.1 General configuration of Android projects

  • Permission configuration: add the network access permission in AndroidManifest.xml

    <uses-permission android:name="android.permission.INTERNET"/>
    
  • Add the following configuration in MSDKConfig.ini, which is used to indicate the request on whether to use a game app:

    Game apps are set to 1, and non-game apps are set to 0

     [HMS channel configuration]
     HMS_IS_GAME_APP = 1
    
  • PProguard obfuscation configuration:

    -ignorewarnings 
    -keepattributes *Annotation* 
    -keepattributes Exceptions 
    -keepattributes InnerClasses 
    -keepattributes Signature 
    -keepattributes SourceFile,LineNumberTable 
    -keep class com.hianalytics.android.**{*;} 
    -keep class com.huawei.updatesdk.**{*;} 
    -keep class com.huawei.hms.**{*;}
    
  • Put the downloaded agconnect-services.json configuration file into the following paths to import it into the project

    • Unity - {Unity project root directory}/Assets/StreamingAssets/agconnect-services.json
    • UnrealEngine - {UnrealEngine project root directory}/Source/ClientUETest/Resources/agconnect-services.json

VI. Function description

4.1 Login function

  • HMS login requires that the user's mobile phone has installed Huawei Mobile Services. If not, it will prompt the user to install it on his phone. The error code is 15.

V. FAQ

5.1 In UE4.23 and higher versions, it will be reported that minSdkVersion is set to be too small when Android APK is compiled

  1. The following configuration has been added to the AndroidManifest.xml file of MSDKHMS to solve this problem
     <uses-sdk tools:overrideLibrary="com.huawei.hmf.tasks,
                                      com.huawei.android.hms.hwid,
                                      com.huawei.android.hms.base,
                                      com.huawei.hms.base.availableupdate,
                                      com.huawei.hms.stats,
                                      com.huawei.hms.base.ui,
                                      com.huawei.hms.base.device,
                                      com.huawei.hms.log,
                                      com.huawei.agconnect.core" />
    
  2. But this configuration cannot be recognized in UE4.23. The game can manually add configuration in the AndroidManifest.xml or APL.xml file in the root directory of the project to solve this problem. The APL file's reference example is as follows (the following configuration includes the dependency of XG Huawei vendor push):

    <androidManifestUpdates>
       <addElements tag="manifest">
             <uses-sdk tools:overrideLibrary="com.huawei.hmf.tasks,com.huawei.android.hms.hwid,com.huawei.android.hms.base,com.huawei.hms.base.availableupdate,com.huawei.hms.stats,com.huawei.hms.base.ui,com.huawei.hms.base.device,com.huawei.hms.log,com.huawei.agconnect.core,com.huawei.android.hms.push,com.huawei.android.hms.openid" tools:ignore="MultipleUsesSdk" xmlns:tools="http://schemas.android.com/tools"/>
       </addElements>
    </androidManifestUpdates>
    



Copyright © 2024 MSDK.
All rights reserved.

results matching ""

    No results matching ""