Integration of HMS core capabilities in Flutter App 2mg.in Part-1

Shiddalingeshwar M S
3 min readOct 29, 2021

In this article, we will be integrating Account Kit and Ads Kit in 2mg.in app. Flutter plugin provides simple and convenient way to experience authorization of users. Flutter Account Plugin allows users to connect to the Huawei ecosystem using their Huawei IDs from the different devices such as mobiles phones and tablets, added users can login quickly and conveniently sign in to apps with their Huawei IDs after granting initial access permission.

Introduction

In this article, we will be integrating Account Kit and Ads Kit in 2mg.in app. Flutter plugin provides simple and convenient way to experience authorization of users. Flutter Account Plugin allows users to connect to the Huawei ecosystem using their Huawei IDs from the different devices such as mobiles phones and tablets, added users can login quickly and conveniently sign in to apps with their Huawei IDs after granting initial access permission.

HUAWEI Ads Publisher Service is a monetization service that leverages Huawei’s extensive data capabilities to display targeted, high quality ad content in your apps to the vast user base of Huawei devices.

Following ads has been covered in this article.

  • Rewarded Ad
  • Banner Ad
  • Interstitial Ad
  • Splash Ad
  • Native Ad
  • Roll Ad

Development Overview

You need to install Flutter and Dart plugin in IDE and I assume that you have prior knowledge about the Flutter and Dart.

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 1.7 or later.
  • Android studio software or Visual Studio or Code installed.
  • HMS Core (APK) 4.X or later.

Integration process

Step 1: Create flutter project

Step 2: Add the App level gradle dependencies. Choose inside project Android > app > build.gradle

Root level gradle dependencies

App level gradle dependencies

Step 3: Add the below permissions in Android Manifest file.

Step 4: Download flutter plugins

Flutter plugin for Account kit

Flutter plugin for Ads kit

Step 5: Add downloaded file into parent directory of the project. Declare plugin path in pubspec.yaml file under dependencies.

Add path location for asset image

Let’s start coding

How do I add Huawei button?

How do I signIn using Huawei ID?

How do I show Bannar Ad?

How do I show Interstitial Ad?

How do I revoke authorization?

Result

Tricks and Tips

  • Make sure that downloaded plugin is unzipped in parent directory of project.
  • Makes sure that agconnect-services.json file added.
  • Make sure dependencies are added yaml file.
  • Run flutter pug get after adding dependencies.
  • Make sure that service is enabled in agc.

Conclusion

In this article, we have learnt to integrate Account Kit, Ads kit into Flutter 2mg.in. Account kit allows you login with Huawei ID, Ads kit lets you efficient ways to monetize your app and supports different types of ads implementations.

Thank you so much for reading, I hope this article helps you to understand the Huawei Account kit and Ads kit in flutter.

Reference

Ads Kit

Account Kit

Checkout in Forum

--

--