In this documentation we explained how to use Huawei-Admob mediation with in the different platforms.
Banner Ad | Interstitial Ad | Rewarded Ad | Native Ad | |
---|---|---|---|---|
Native (Java/Kotlin) | ✅ | ✅ | ✅ | ✅ |
Unity | ✅ | ✅ | ✅ | ❌ |
React Native | ✅ | ✅ | ✅ | ✅ |
Flutter | ✅ | ✅ | ✅ | ❌ |
Cordova | ✅ | ✅ | ❌ | ❌ |
- Sign in to Huawei Developer Console and create an AdUnit
Make sure to check the article on How to use Huawei Ads with AdMob mediation ?
- Sign in to Google AdMob console
- Go to "Mediation -> Create a new Mediation Group" (or, use one of the existing Mediation groups)
- Under the "Ad Sources" section, click "Add Custom Event" Give it a label (eg: Huawei Banner Custom Event) and an eCPM, click "Continue"
- Enter the class name "com.hmscl.huawei.admob_mediation.all_ads" as the Class Name, and your Huawei's AdUnit ID from step 1 as the parameter
- Add the adapter and its dependencies into your project
- Configuration of custom event is done.
Make sure to check the article on How to Use Huawei Ads with Google Ad Manager ?
- Sign in to Google Ad Manager console
- Add Huawei as a Ad Network Company by selecting Other company in Ad Network section
- Go to "Delivery -> Yield groups" (or, use one of the existing groups)
- Create a yield group and add Huawei as a yield partner
- Enter the class name "com.hmscl.huawei.admob_mediation.all_ads" as the Class Name, and your Huawei's AdUnit ID from step 1 as the parameter
- Add the adapter and its dependencies into your project
- Configuration of custom event is done.
In the project-level build.gradle, include Huawei's Maven repository.
repositories {
google()
jcenter() // Also, make sure jcenter() is included
maven { url 'https://developer.huawei.com/repo/' } // Add this line
maven {url "https://jitpack.io"} // Add this line
}
...
allprojects {
repositories {
google()
jcenter() // Also, make sure jcenter() is included
maven { url 'https://developer.huawei.com/repo/' } //Add this line
maven {url "https://jitpack.io"} // Add this line
}
}
dependencies {
//Huawei Ads Prime
implementation 'com.huawei.hms:ads-prime:<latest_version>'
//Google AdMob SDK
implementation 'com.google.android.gms:play-services-ads:<latest_version>'
//Optional: Google Consent SDK
implementation "com.google.android.ads.consent:consent-library:<latest_version>"
}
NOTE: If your app can run only on Huawei mobile phones, you can integrate the Huawei Ads Lite SDK instead of Huawei Ads SDK (Optional)
dependencies {
...
//Huawei Ads Lite
implementation 'com.huawei.hms:ads-lite:<latest_version>'
...
}
NOTE: To implement Huawei Ads Admob mediation adapter :
dependencies {
...
//If your app uses Google Admob SDK 20.6.0 and above versions, use :
implementation 'com.github.Explore-In-HMS:huawei.ads.admob_mediation:<latest_version_for_above_20.6.0>'
...
//If your app uses Google Admob SDK 20.5.0 and below version, use :
implementation 'com.github.Explore-In-HMS:huawei.ads.admob_mediation:<latest_version_for_below_20.5.0>'
}
- Check the latest Huawei Ads SDK here
- Check the latest Google AdMob SDK here
- Check the latest Google Consent SDK here
- Check the latest version of adapter for Admob SDK 20.6.0 or above
- Check the latest version of adapter for Admob SDK 20.5.0 or below
Important: To add Huawei Ads Kit SDK and Mediation adapter, the native project should be opened with Android Studio.
The HUAWEI Ads SDK (com.huawei.hms:ads) has integrated the required permissions. Therefore, you do not need to apply for these permissions.
android.permission.ACCESS_NETWORK_STATE: Checks whether the current network is available.
android.permission.ACCESS_WIFI_STATE: Obtains the current Wi-Fi connection status and the information about WLAN hotspots.
android.permission.BLUETOOTH: Obtains the statuses of paired Bluetooth devices. (The permission can be removed if not necessary.)
android.permission.CAMERA: Displays AR ads in the Camera app. (The permission can be removed if not necessary.)
android.permission.READ_CALENDAR: Reads calendar events and their subscription statuses. (The permission can be removed if not necessary.)
android.permission.WRITE_CALENDAR: Creates a calendar event when a user clicks the subscription button in an ad. (The permission can be removed if not necessary.)
Before building the APK, configure the obfuscation configuration file to prevent the HUAWEI Ads SDK () from being obfuscated.
Open the obfuscation configuration file proguard-rules.pro in the app-level directory of your Android project, and add configurations to exclude the HUAWEI Ads SDK from obfuscation.
-keep class com.huawei.openalliance.ad.** { *; }
-keep class com.huawei.hms.ads.** { *; }
To allow HTTP and HTTPS network requests on devices with targetSdkVersion 28 or later, configure the following information in the AndroidManifest.xml file:
<application
...
android:usesCleartextTraffic="true"
>
...
</application>
New Smart Banner & Advanced Banner type support added. Oversized banner issue is fixed
Library updated to support Admob's new mediation classes.
Update Huawei Ads SDK. Resolved the compatibility issue of the network component OkHttp.
Minor fixes.
Logs issue fixed.
Logging structure updated, code infrastructure optimized.
Bug fix.
AdListener methods has been added.
OnLoaded() methods has been added .
Ads version updated and Zip Path Traversal issue is fixed.
Min SDK updated.
Transparency & Consent Framework v2.0 and personalized & non-personalized ads configurations are integrated.
Banner Ad | Interstitial Ad | Rewarded Ad | Native Ad | |
---|---|---|---|---|
Native (Java/Kotlin) | ✅ | ✅ | ✅ | ❌ |
Unity | ✅ | ✅ | ✅ | ❌ |
If you want to integrate Ironsource network through Admob mediation follow these steps.
- Add Admob for mediation at IronSource SDK Networks.
- Enter your App ID and Ad Unit ID from Admob.
- Add IronSource admob adapter and gms play services dependency to the project.
If you have IronSource mediation with Admob you just need to integrate the Huawei admob mediation adapter and make the necessary changes we mentioned on the Admob panel.
Follow here for the integration steps
If there is only IronSource ads in the application, admob mediation must be done first from the IronSource panel, and then Huawei admob adapter must be added.
For this, admob mediation should be done on IronSource first, and then admob mediation adapter should be added to the project as it was done in the first step.
dependencies {
implementation 'com.google.android.gms:play-services-ads:20.2.0'
implementation 'com.ironsource.adapters:admobadapter:4.3.22'
implementation 'com.huawei.hms:ads:3.4.47.302'
implementation 'com.github.Explore-In-HMS:huawei.ads.admob_mediation:<latest_version>'
}
This section demonstrates how to use AdMob mediation feature with Huawei Ads Kit on Native android app.
Make sure to check the article on How to use Huawei Ads with AdMob mediation (Native Android)
Firstly, integrate the Admob SDK for Android
Admob Android SDK can be used for all ad types.
Note :
- Developers can find app level build.gradle in their project from "app-folder/app/build.gradle"
- If you use the native ad format in your application, please submit a ticket here to get support from Huawei.
To use Banner ads in Native android apps, please check the Admob SDK. Click here to get more information about Admob SDKs Banner Ad development.
To use Interstitial ads in Native android apps, please check the Admob SDK. Click here to get more information about Admob SDKs Interstitial Ad development.
To use Rewarded ads in Native android Rewarded, please check the Admob SDK. Click here to get more information about Admob SDKs Banner Ad development.
To use Native ads in Native android apps, please check the Admob SDK. Click here to get more information about Admob SDKs Native Ad development.
This section demonstrates how to use Admob mediation feature with Huawei Ads Kit on Unity.
Make sure to check the article on How to use Huawei Ads with Supported Ad Platforms in Unity ?
Supported Ad Formats are: Banner Ads, Interstitial Ads and Rewarded Ads.
Firstly, integrate the Admob Unity SDK to Unity.
For more details on Admob Unity SDK visit here
To use Banner ads in Unity , please check the Admob Unity SDK. Click here to get more information about Admob Unity SDKs Banner Ad development.
To use Interstitial ads in Unity, please check the Admob Unity SDK. Click here to get more information about Admob Unity SDKs Interstitial Ad development.
To use Rewarded ads in Unity, please check the Admob Unity SDK. Click here to get more information about Admob Unity SDKs Banner Ad development.
Make sure to switch to the Android Platform from Build Settings -> Android -> Switch Platform
Edit -> Project Settings -> Player -> Other Settings
In Other Settings set minimum API level to at least 21.
Edit -> Project Settings -> Player -> Publishing Settings
In Publishing Settings select “Custom Main Gradle Template” , “Custom Base Gradle Template” and “Custom Greadle Properties Template”
This will let you override mainTemplate.gradle , baseProjectTemplate.gradle and gradleTemplate.properties files in the project.
baseProjectTemplate.gradle is equal to project-level gradle so you have to include Huawei's Maven repositories from the Integrate the Huawei Mediation SDK section from here
mainTemplate.gradle is equal to app-level build.gradle so you have to include dependencies from the Integrate the Huawei Mediation SDK section from here.
Open gradleTemplate.properties and add the following lines
android.useAndroidX=true
android.enableJetifier=true
After these configurations is completed you can display Huawei Ads.
Note: In case of any error on aaptOptions you can add the following line to aaptOptions in launcherTemplate.gradle which you override it by enabiling it from Edit -> Project Settings -> Player -> Publishing Settings
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
This section demonstrates how to use AdMob mediation feature with Huawei Ads Kit on React-Native.
Make sure to check the article on How to use Huawei Ads with AdMob mediation (React Native)
Important: There is no official React Native SDK for Admob therefore third party SDKs has been used in the demonstration.
Firstly, integrate the React Native Admob SDKs as below depending on type of ad
Note: Developers can find app level build.gradle in their project from "app-folder/app/build.gradle"
For Banner , Interstitial and Rewarded Ad type's react-native-admob SDK can be used.
For Native ad type react-native-admob-native-ads SDK can be used.
Then use the following sample codes based on specific ad types.
<AdMobBanner
adSize="fullBanner"
adUnitId={BannerAdId}
testDevices={[AdMobBanner.simulatorId]}
onAdFailedToLoad={error => console.error(error)} />
AdMobInterstitial.setAdUnitID(InterstitialAdId);
AdMobInterstitial.setTestDevices([AdMobInterstitial.simulatorId]);
AdMobInterstitial.requestAd().then(() => AdMobInterstitial.showAd());
AdMobRewarded.setAdUnitId(RewardedAdId);
AdMobRewarded.requestAd().then(() => AdMobRewarded.showAd());
<NativeAdView
adUnitID= {NativeAdId}
onAdFailedToLoad={error => console.error(error)} />
This section demonstrates how to use AdMob mediation feature with Huawei Ads Kit on Flutter.
Make sure to check the article on How to use Huawei Ads with AdMob mediation (Flutter)
Important: There is no official Flutter SDK for AdMob therefore third party SDKs has been used in the demonstration.
Firstly, integrate the Flutter_ AdMob _SDKs as below depending on type of ad
Note: Developers can find app level build.gradle in their project from "app-folder/android/app/build.gradle"
For Banner and Interstitial Ad types admob_flutter SDK can be used.
For Banner and Rewarded Ad types googleads-mobile-flutter SDK can be used.
Native ads are not supported with this SDK. To use Native ads in Flutter app, please check the HMS Core Ads Kit Flutter SDK. Click here to get more information about HMS Core Flutter SDKs Native Ad development.
Then use the following sample codes based on specific ad types.
…
Admob.initialize();
…
child: AdmobBanner(
adUnitId: "Your Banner Ad Unit ID",
adSize: AdMobBannerSize.[Selected_Banner_Size],
listener: (AdmobAdEvent event,
Map<String, dynamic> args) {
handleEvent(event, args, 'Banner');
},
onBannerCreated:
(AdmobBannerController controller) {
},
),
…
…
Admob.initialize();
…
interstitialAd = AdmobInterstitial(
adUnitId: "Your Intersitatial Ad Unit ID",
listener: (AdmobAdEvent event, Map<String, dynamic> args) {
if (event == AdmobAdEvent.closed) interstitialAd.load();
handleEvent(event, args, 'Interstitial');
},
);
class RewardedAd extends AdWithoutView {
...
static final String testAdUnitId = Platform.isAndroid
? 'Your Rewarded Ad Unit ID'
: 'Your Rewarded Ad Unit ID';
@override
Future<void> load() async {
await instanceManager.loadRewardedAd(this);
}
}
This section demonstrates how to use AdMob mediation feature with Huawei Ads Kit on Cordova.
Make sure to check the article on How to use Huawei Ads with AdMob mediation (Cordova)
Important: There is no official Cordova SDK for AdMob therefore third party SDKs has been used in the demonstration.
Firstly, integrate the Cordova_ AdMob _SDKs as below depending on type of ad
Note: Developers can find app level build.gradle in their project from "app-folder/platforms/android/app/build.gradle"
For Banner and Interstitial Ad types admob-plus SDK can be used.
Rewarded ads are not supported with this SDK. To use Rewarded ads in Cordova app, please check the HMS Core Ads Kit Cordova SDK. Click here to get more information about HMS Core Cordova SDKs Rewarded Ad development.
Native ads are not supported in Cordova. To use Native Ads in Cordova App please check the HMS Core Ads Kit Cordova SDK. Click here to get more information about HMS Core Cordova SDK Native Ad development.
Then use the following sample codes based on specific ad types.
showBannerAd() {
const banner = new admob.BannerAd({
adUnitId: '[Enter BannerAdID here]',
})
return banner.show({ position: 'bottom' })
},
showInterstitialAd() {
const interstitial = new admob.InterstitialAd({
adUnitId: '[Enter InterstitialAdID here]',
})
return interstitial.load().then(() => interstitial.show())
},
Banner Ad |
Interstitial Ad |
Rewarded Ad |
Native Ad |
Banner Ad |
Interstitial Ad |
Rewarded Ad |
Native Ad |