Intermediate: How to Integrate Huawei kits (Remote Configuration and Crash Kit) into Unity

Introduction

Huawei provides various services for developers to make ease of development and provides best user experience to end users. In this article, we will cover integration of Huawei Kit in Unity Project using Official Plugin (Huawei HMS Core App Services). Here we will cover below kits.

  • AppLinking
  • Ads Kit

AppLinking Introduction

App Linking allows you to create cross-platform links that can work as defined regardless of whether your app has been installed by a user. A link created in App Linking can be distributed through multiple channels to users. When a user taps the link, the user will be redirected to the specified in-app content. In App Linking, you can create both long and short links. To identity the source of a user, you can set tracing parameters when creating a link of App Linking to trace traffic sources. By analysing the link performance of each traffic source based on the tracing parameters, you can find the platform that can achieve the best promotion effect for your app.

In App Linking, you can create both long and short links. It automatically identifies the source of a user and you can set tracing parameters when creating a link of AppLinking which helps you to trace traffic sources. By analysing the link performance of each traffic source based on the tracing parameters, you can find the platform that can achieve the best promotion effect for your app and also you can see the data statics of AppLinking in ag-console.

Service use case

  • Waking Up Inactive Users/Increasing Views of a Specific Page
  • Converting Mobile Website Users into Native App Users
  • Tracing Traffic Sources in Daily Marketing to Identity the Most Effective Marketing Platform

Ads Kit Introduction

Huawei Ads Kit leverages Huawei devices and Huawei’s extensive data capabilities to provide with the Publisher Service, helping to monetize traffic. Meanwhile, it provides the advertising service for advertisers to deliver personalized campaigns or commercial ads to Huawei device users.

The video on this page introduces traffic monetization through Huawei Ads Kit and the process for advertisers to display ads.

Development Overview

You need to install Unity software and I assume that you have prior knowledge about the unity and C#.

Hardware Requirements

  • A computer (desktop or laptop) running Windows 10.
  • A Huawei phone (with the USB cable), which is used for debugging.

Software Requirements

  • Java JDK installation package.
  • Unity software installed.
  • Visual Studio/Code installed.
  • HMS Core (APK) 4.X or later.

Follows the steps.

1. Create Unity Project.

  • Open unity Hub.
  • Click NEW, select 3D, Project Name and Location.
  • Click CREATE, as follows:

2. Click Asset Store, search Huawei HMS Core App Services and click Import, as follows.

3. Once import is successful, verify directory in Assets> Huawei HMS Core App Services path, as follows.

4. Choose Edit > Project Settings > Player and edit the required options in Publishing Settings, as follows.

5. Generate a SHA-256 certificate fingerprint.

To generating SHA-256 certificate fingerprint use below command.

6. Download agconnect-services.json and copy and paste to Assets > Plugins > Android, as follows.

7. Choose Project Settings > Player and update package name.

8. Open LauncherTemplate.gradle and add below lines.

9. Open AndroidManifest file and add below permissions.

11. Open “mainTemplate.gradle” and add lines, as follows.

12. Create Scripts folder and create a class.

HMSAppLinking.cs

AndroidManifest.xml

13. Follow the steps, as shown in image:

a. Assign HMSAppLinking script to Canvas.

b. Select Button and add onClick event.

c. Assign button to button handler.

14. Onclick Button Handler you find your script HMSAppLinking (As per your script name) and attach method as per below screenshot.

15. To build apk andrun in device, choose File > Build Settings > Build for apk or Build and Run for run on connected device.

Result

  1. Click on GenerateLink Button link is generated as per below screenshots.

2. Click on Ads button, find the result in image.

Tips and Tricks

  • Always use the latest version of the library.
  • Add agconnect-services.json file without fail.
  • Add SHA-256 fingerprint without fail.
  • Make sure dependencies added in build files.
  • Make sure you have enable debug mode.

Conclusion

In this article, we have learnt integration of Huawei AppLinking service and Ads Kit into Unity Game development. In App Linking, you can create both long and short links which identify in-app link for app and web automatically.

Thanks for reading the article, please do like and comment your queries or suggestions.

References

App Linking:

HMS Ads Kit:

Unity Offical:

Original Source:

https://forums.developer.huawei.com/forumPortal/en/topic/0201557451499860275?ha_source=hms1