How to generate certificates and run the application on Harmony Lite wearable - Huawei Developers

Introduction
Security of the code and build is very important for all developers. To ensure it, Harmony has different levels of certificates to issue to run the application. In this article, we are going to learn about generating these certificates and the procedure to run the build on the real device. Following are the certificates which we required to generate the build.
1. KeyStore (*.p12)
2. Profile File (*.p7b)
3. CertPath File (*.cer)
Requirements
1. DevEco IDE
2. Huawei Developer Account
Flow Chart
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Certificate generation process
KeyStore file generation
Step 1: Create the project on the console, navigate to AG connect, select My Apps, and Add app.
Step 2: Choose Build > Generate Key
Step 3: Click New in Generate Key window.
Step 4: Enter details in Create Key Store and click OK, IDE will generate a .p12 file to given path.
CSR file generation
Step 1: After generating it add remaining details and click on the Generate Key and CSR.
Step 2: Select CSR File Path and, then click OK. Your CSR file will be generated.
Step 3: Two files will be generated on the path you have provided (.csr and .p12).
CER file generation
Step 1: Navigate to AppGallery connect, then open users and permissions.
Step 2: Choose Certificate management > New certificate, upload .csr file generated, and then click Submit.
Step 3: Your certificate will be listed on the users and permission section, from there you can download the .cer file.
Adding device on the console
Step 1: Install the DevEco assistant application on your android smartphone (You can download it from AppGallery), then connect the watch through the Huawei health application. Then open the app and find out the UDID.
Step 2: Get the UDID of your device using the DevEco assistant application.
Step 3: Choose Device management > Add device, enter details in Device information and then click Submit.
Provision file generation
Step 1: Now go back to your application window.
Step 2: Then select the HAP Provision profile from the left menu.
Step 3: Click Add and enter details, and then click Submit.
Step 4: Add the required details on the console.
Step 5: At the end, you will be generated with two files one is a provisional file (.p7b) and another on is Certpath file (.cer). Come back to the IDE and add the certificates to the project structure (Choose File > Project Structure).
Step 6: Add the certificates in Modules.
Step 7: Click Apply, and then click OK.
Build and run the application
Step 1: Now build the Haps as given on the screenshot.
Step 2: Find the Hap file on build folder of your module.
Step 3: Copy the file and paste on the /sdcard/haps folder of your Android smartphone.
Step 4: Find the newly added application on the DevEco assistant app. It shows the application which is there on the /sdcard/haps path.
Step 4: Click install, it will start the installation and wait for the success toast message. Once you get the success toast you can see your application on your wearable.
Tips and Tricks
There are only two debug and one release certificates allowed at a time in the AG console. So make sure that you are saved the .csr file for the future use.
Even if you remove the certificate from the console also, the app will work properly without any issue.
Don’t add package name which is having more than 30 characters. Right now only 30 characters are accepted on the Lite wearable.
Conclusion
In this article, we are learned how to generate and add the required certificate to run and release the application. We have also learned about the DevEco Assistant app.
Reference
Building your app documentation:
HarmonyOS Document
developer.harmonyos.com
Harmony Official document:
Document
developer.harmonyos.com
DevEco Studio User guide:
Document
developer.harmonyos.com

Related

HUAWEI Drive Kit Development Process (Part*1)

More information like this, you can visit HUAWEI Developer Forum​
Hey Dear Developers,
Do you have any questions with HUAWEI Drive Kit developing process?
If YES, here will give you some help.
HUAWEI Drive Kit ("Drive Kit") allows you to create apps that use the HUAWEI Drive Kit service.
Drive Kit provides cloud storage for your apps, enabling users to store files that are created while using your apps, including photos, videos, and documents, in HUAWEI Drive ("Drive") as well as download, synchronize, share, search for, and comment on these files and reply to comments.
Drive Kit also provides comprehensive data protection, empowering users to manage their data securely and conveniently.
The current core capabilities of Drive Kit include uploading, downloading, and searching for files in Drive, commenting on files, replying to comments, querying file changes, and receiving notifications.
The figure below shows the development process, and the red area represents the preparations procedures (step 1- preparations).
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Furthermore, the preparation procedures will be divided into 3 parts:
1. Configuring App information in AppGallery Connect (mandatory procedures);
2. Preparing for client development;
3. Preparing for server development.
Before you start developing an app, configuring App information in AppGallery Connect (mandatory procedures):
l Registering as a Developer:
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.
l Creating an App:
Create an app by referring to Creating an App at the AppGallery Connect and upload a temporary APK.
Set the following parameters as described:
Ø Package type: APK (Android app)
Ø Device: Mobile phone
Ø App category: App
NOTICE:
AppGallery Connect reads the temporary APK to obtain the app package name. Therefore, the temporary APK name must be the same as the released APK name.
l Generating a Signing Certificate Fingerprint:
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 SDK. Before using the HMS service, you must locally generate a signing certificate fingerprint and configure it in AppGallery Connect.
Please ensure that the following conditions are met:
Ø You have created the app's signature file.
Ø The JDK has been installed on your PC.
Perform the following steps:
Ø Open the command line tool (using the cmd command) and run the cd command to go to the directory where keytool.exe is located.In the following example, the Java program is installed in Program Files (x86) in the C drive.
Ø Run keytool -list -v -keystore <keystore-file> and respond as prompted.
In the preceding command, <keystore-file> is the complete path to the app's signature file.
Example:
Code:
C:\Program Files (x86)\Java\jdk1.7.0_25\bin>keytool -list -v -keystore
E:\HMS_SDK_2.5.1.300\Sample\HMSSdkSample_2.5.1.300_AS\HmsSample\android.keystore.jks
Ø Obtain the SHA-256 fingerprint from the result.
Configuring the Signing Certificate Fingerprint:
1.Sign in to AppGallery Connect and select My apps.
2.Find your app from the list and click the link under Android App in the Mobile phone column.
3.Go to Develop > Overview > App information and set SHA-256 certificate fingerprint to the SHA-256 fingerprint that is generated from the preceding section of Generating a Signing Certificate Fingerprint.
4.After completing configuration, click √
Enabling Required Services:
1.Log on to AppGallery Connect and select My apps.
2.Click the product to which your app belongs. The app information page is displayed.
3.Click the Develop tab, click the icon next to Overview, and then select Manage APIs.
4.Enable the required services.
For more details, please refer to Enabling Services.
'Preparing for client development & server development' are coming soon…
More information:
https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/drivekit-introduction

Coding Assistant - Automatic Environment Configuration of Push Kit in One Click

More information like this, you can visit HUAWEI Developer Forum​
Introduction:
Coding Assistant provides HMS Core APIs and sample code. We only need to drag and drop scenario cards to integrate the corresponding scenarios. Here we can simply configure the Push Kit integration environment with one click, and the tool will automatically complete the configuration.
HMS Core Tool Kit Introduction:
HMS Core Tool Kit is a plug-in Installed in Android studio to facilitate app creation, coding, conversion, debugging, testing and release. It helps to integrate HMS Core API in the most efficient way and at the lowest possible cost.
To know more about HMS tool Kit and installation process use the Link.
Integrating Procedure:
Previously we may have needed to set many configuration items while integrating push Kit and have to check them repeatedly to avoid omission. To address this issue Huawei sorted the integration process and placed the configuration items into an automatic process. This is called the automatic environment configuration in one click mode.
So, click Start Configuration to initiate an automatic check whether configuration is required for integration to be completed. If not, some will automatically be completed while the rest will have to be processed as prompted. Click Retry to check whether all of the configuration items are completed. This ensures that the entire configuration process is clear and there are no omissions.
Development Based on Scenarios and Steps:
Huawei provides scenario-based and step-based development modes.
For scenario-based development, drag a scenario card to a project to automatically insert related code, configurations, and dependencies.
For step-based development, access a card to view the detailed steps and API code snippets of a scenario, and copy code snippets to a project.
Here we are using scenario-based development.
Steps for Integrating Push Kit Via Coding Assistant:
1. Go to HMS > Coding Assistant
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2. Login Via opened browser
3. Provide access permission
After log in, it will be redirected to HUAWEI Dev Eco Studio home Page.
Configuration Wizard
Configuration Wizard will help us to quickly complete the necessary preparations such as registering an app and generating a signing certificate fingerprint so that we do not spend more time.
1. To setup development environment, click Configuration.
2. In Configuration Wizard, select Choose your team name, Choose kit, Choose your module and Certificate to generate the fingerprint.
Click Start Enviornmrnt Check, as follows.
3. Click Go to environment configuration, as show in below image.
Note: To solve the issues in Environment Check as App Gallery Connect cannot locate your application, Data storage location has not been set yet etc.
4. Configuration Results will show details of failed steps. Go to each and every failed steps and click the corresponding Link.
5. Click Link, it will redirect to AppGallery.
Note: Here the first issue is there is no application in AppGallery with the same package name as the application created in Android Studio. So in AppGallery we have to create an application with the same package name. We can check Event Log and can verify which steps are executed successfully.
6. Create New project.
7. Click Add app in General Information for creating app
8. Enter App name, Package name, App category and Default language.
9. In Configuration Result, click Retry, it will provide new result and prompt to set data storage location.
10. After click on Link, it redirect to AppGallaery Conect and we need to set Data Storage Location.
11. Select Data Storage location.
12. In Configuration Result, click Retry, it will provide new Configuration Results.
It prompts to enable service manually.
13. In AppGallery Connect, click Enable now Huawei PushKit.
14. In Configuration Result, click Retry, it will provide new Configuration Results. It prompts to enable API.
15. In AppGallery Connect, Enable Push Kit API as shown below.
16. In Configuration Result, click Retry. Finally it will provide success message.
Note: Check Event Log and see the details.
17. In Configuration Results click Go to Coding Assistant.
This is not the end. For full content, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201339927413030084&fid=0101188387844930001

Integration Practice | Sending Messages by HUAWEI Push Kit in Cocos

Cocos Creator has supported HMS Core and HUAWEI AppGallery Connect, through which you can quickly release your games with one click, reducing such complex operations as the SDK integration and app upload during development. In this way, you can build high-quality and innovative apps to improve game experience.
Based on this guide, you can learn how to send messages by Push Kit in Cocos step by step.
Procedure Overview
1. Create a game on the Cocos website, and create the game project in Cocos Creator.
2. Create an app and configure the app information in AppGallery Connect, configure Cocos SDKHub and the building flow, and add the HUAWEI_HMS (Push) plugin and select HUAWEI AppGallery Connect from SDKHub Configuration.
3. Perform coding to obtain a token and build an APK.
4. Test the function of sending notification messages and data messages.
Procedure Details
Step 1: Create a game on the Cocos website, and create the game project in Cocos Creator.
1. Visit https://passport.cocos.com/auth/signup, and sign in with a Cocos developer account. (If you have no account, register one.) Then create a game.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2. Visit http://www.cocos2d-x.org/products#creator, and download and install Cocos Creator.
3. Start Cocos Creator, choose Project, and click New. In the window that is displayed, configure project information, and click Save. The project creation is completed.
If the following error occurs during creation, download Editor.
In Cocos Creator, choose Editor, select version 2.4.2 on the right, and click Download.
Step 2: Create an app and configure the app information in AppGallery Connect, configure Cocos SDKHub and the building flow, and add the HUAWEI_HMS (Push) plugin and select HUAWEI AppGallery Connect from SDKHub Configuration.
1. Create an app and configure the app information in AppGallery Connect by referring to the guide in https://developer.huawei.com/consum...re-Guides/android-config-agc-0000001050170137.
The key steps include:
Generating a signing certificate fingerprint
Configuring the signing certificate fingerprint
Setting a data storage location
Enabling required services
Downloading the agconnect-services.json file
After the app information configuration, perform configuration in Cocos Creator.
2. Choose Panel > Service.
3. Select your project.
Select Cocos SDKHub on the page that is displayed.
4. Click Plugin Manage.
5. Select Push and click OK. The page shown in the preceding figure is displayed.
6. Move the cursor to Not Configured in Params. The editing icon is displayed. Click it.
7. Select a required JSON file, and click OK.
8. Choose Project > Build.
The Build panel is displayed on the right.
9. Set SDKHub Configuration to HUAWEI AppGallery Connect, and click Build.
If the following error occurs during building, install NDK.
After the installation, click Compile. The progress status becomes completed.
Step 3: Perform coding to obtain a token and build an APK.
The following figure shows the project structure.
In Cocos Creator, select js-sdkhub.js file from Assets at the lower left corner.
More information, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201368424613350372&fid=0101187876626530001
https://forums.developer.huawei.com/...87876626530001 This seems a new platform for asking integration questions about HMS. I will try this.
Sherlock F said:
https://forums.developer.huawei.com/...87876626530001 This seems a new platform for asking integration questions about HMS. I will try this.
Click to expand...
Click to collapse
Yep, welcome to experience it~

How Can I Use the HUAWEI Game Service Demo Provided by Unity? - Part1

HUAWEI Game Service provides various capabilities, including automatic game update check, player information obtaining, floating window, game addiction prevention, game achievements, and leaderboards. Unity provides the HMS Core App Services SDK and demo for global developers to quickly integrate these capabilities and release their games on Huawei devices.
Let’s try this SDK.
Objective: Run the game demo provided by Unity to debug basic functional APIs, including init and APIs for HUAWEI ID sign-in.
Documentation
https://docs.unity.cn/cn/Packages-cn/[email protected]/manual/appgallery.html
Demo Download Path
https://github.com/Unity-Technologies/HMSSDKSample
The demo to be run is as follows.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Preparations
Step 1: Register as a Huawei developer, create a joint operations game, and add it to a project.
For details about the operations, please refer to the official documentation: https://developer.huawei.com/consum...connect-Guides/appgallerykit-preparation-game.
The following figure shows an example.
Step 2: Download the agconnect-services.json file in AppGallery Connect.
1. Go to the Project settings page of the project to which your game belongs. The following message is displayed. In this example, Manually enter the package name is selected.
2. Download the agconnect-services.json file.
Step 3: Replace the JSON file in the demo provided by Unity.
Replace the downloaded JSON file with the following file.
Step 4: Configure related files in the Assets/Plugins/Android directory.
For details about the operations, please refer to the Unity documentation:
https://docs.unity.cn/cn/Packages-c...configuration-files-into-assetspluginsandroid
Opening the Demo in UnityEditor
If you have not installed UnityEditor, you can install its latest version and Unity Hub by performing the operations in the following post. If you have installed UnityEditor, follow the operations below.
https://forums.developer.huawei.com/forumPortal/en/topic/0204435788744370088?fid=0101187876626530001
Step 1: Add a Unity project in Unity Hub.
The following figure shows how your project is displayed.
Note that you need to choose the correct Unity version when opening the project.
Step 2: Double-click the project and go to UnityEditor.
Ignore this message and click Continue.
Again, click Continue and wait for the project import to complete.
The demo page is as follows.
Completing the Build Settings for the Android Game
Step 1: Choose File > Build Settings….
Step 2: Click Player Settings… and the Project Settings tab page is displayed.
Note: If you have not installed the Android module, install it in UnityEditor as prompted. Restart UnityEditor to make the module take effect.
Step 3: Replace the game information, including Package Name and Version, with your actual game information configured in HUAWEI AppGallery Connect.
Step 4: Generate a signature file for your game.
Note: If a message is displayed, indicating that the JDK directory is not set or invalid, choose Edit > Preference > External Tools and change the default JDK directory. The system will automatically obtain the directory. If the directory cannot be found, you need to reinstall and restart UnityEditor. For details, please watch this video: JDK not found Unity | java development kit is not set or invalid unity.
In this example, the generated signature file is placed here.
Interesting to know it if you want to make a game with unity.
Rebis said:
Interesting to know it if you want to make a game with unity.
Click to expand...
Click to collapse
Thank you for like.

Push Kit Integration with Cocos

Introduction:
This article will demonstrate to Integrate Push kit in Cocos using Huawei HMS Core App Services Plugin. Huawei Push Kit is a messaging service. It establishes a messaging channel from the cloud to devices. By integrating Push Kit, you can send messages to your apps on users devices in real time. This helps to maintain closer ties with users and increases user awareness and engagement with your apps.
Note: Cocos is free but not open source.
Requirements:
1. Cocos Creator tool
2. Notepad++ for editing and writing script
3. HMS Device
4. Android Studio for Analyzing APK and Checking Log
Output:
Push Notification, Data Message.
Steps to Integrate:
1. Install and launch cocos creator.
2. Make sure to configure NDK Root and Android SDK Root in Cocos Creator, choose File> Settings>Select Native Develop.
3. Click in Cocos Dashboard, click New.
Create project name in Name section and click on hello-world and then Create and open.
Click on Project tab and then Build.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Enter Platform, Build Path and Package Name in build window.
Note: The package name should be same in app gallery connect.
In the same build popup, in the keystore section we can use default keystore (default location is /Users/<username>/.android/debug.keystore) and we can generate SHA key or we can create custom keystore and can generate SHA key.In Command line terminal execute the command below and get SHA key:
Code:
keytool -list -v -keystore keystorepath\keystorename.keystore
Steps to create custom key store file:
a) Uncheck use debug keystore
b) In keystore path section click on New button.
c) Enter all the details in New Keystore details and then click Save.
4. Step 1: Create a project in AppGallery using created SHA key
Step 2: Configure the signing certificate fingerprint
Choose Project settings > General information. In the App information area, click the icon next to SHA 256 certificate fingerprint, and enter the obtained SHA-256 certificate fingerprint.
Step 3: Download agconnect-services.json file and put in setting folder in cocos project.
Example:
Right click on Assets folder and then select Open in Explorer
Place agconnect-services.json file inside settings folder
5. Click Enable for Cocos SDKHub in Service tab.
Click on Association button and register project in Cocos Console
Associating a Game in Cocos Creator You can enable third-party services for your app in Cocos Creator. But first, you need to set a Cocos AppID. Select a created game, and click Association, as shown in the following figures.
Select Plugin Manage under Service tab.
Select Push option in Plugin Manage under Service tab.
Place mouse cursor over the "Configured" text so that "Edit" and "Delete" icons will be appeared. Click on edit icon.
Put public key(from AppGallery connect) in the "Payment Public key" field and select "en" option for "Support language" field and then click OK.
Script code for Notification and Data message:
onLoad: function () {
sdkhub.getPushPlugin().startPush();
sdkhub.getPushPlugin().setListener(this.onPushResult, this);
},
onPushResult: function (code, msg) {
console.log("on push result action.");
console.log("code: " + code);
console.log("massage: " + msg);
this.label.string=msg;
this.showToast(code, msg);
switch (code) {
case sdkhub.PushResultCode.kStartPushSucceed:
console.log("kStartPushSucceed", msg);
break;
}
},
6. Click on Build, Compile, Play under the Project tab to generate APK file.
Tips & Tricks:
Make sure to keep the same package name as kept in the Huawei AppGallery Connect project.
Conclusion:
To promote products and launch marketing activities, games, e-commerce apps, and utility apps can call Push Kit APIs to select target audiences by tag and push messages to them, attracting more users and improving the marketing activity conversion rate.
References:
> Note: this version of the documentation has been archived and is no longer maintained. Please move to the latest version. · Cocos Creator
docs.cocos.com

Categories

Resources