How can we display HMS Banner Ads After Successful login using HMS Account Kit ?
Introduction
While integrating multiple kits, we might face some challenges to connect their features together. Here I am going to explain how we can can display HMS Banner Ads After Successful login using HMS Account Kit.
Integrating the HMS Core SDK
It is necessary to add all the required settings as mentioned in HMS Document.
Adding the AppGallery Connect Configuration File
1. Sign in to AppGallery Connect and click My projects.
2. Find your app project and click the app that needs to integrate the HMS Core SDK.
3. Provide the SHA Key, storage location in convention section under project setting.
4. Go to Project settings > General information. In the App information area, download the agconnect-services.json file.
5. Copy the agconnect-services.json file to your app’s root directory.
Configuring the Maven Repository Address for the HMS Core SDK
1. Open the build.gradle file in the root directory and add add the maven url inside the buildscript repositories.
2. Add the class path inside the dependencies section of project build.gradle file.
3. Open the settings.gradle file in the root directory and add add the maven url inside the repositories.
Adding Build Dependencies
1. Open the app-level build.gradle file of your project.
2. Add a build dependency in the dependencies block.
3. Add the AppGallery Connect plugin configuration
Adding Permissions
The Account SDK requires permissions to obtain the network status and Wi-Fi status. Declare the permissions in the AndroidManifest.xml file as follows:
Code Implementation
Here I am using MainActity class for login with HMS Account Kit . User can Login here via Silent sign in or ID Token mode. After login it will call dealWithResultOfSignIn method. We can add our code for Banner Ads there.
I have added Login Button in activity_main.xml. I used constraint layout with id ad_frame.
That’s it. Now you will get your banner image after you successfully sign in via HMS Account Kit.
Reference:
Account Kit Document
Ads Kit Document