- iOS
- Android
This adapter allows you to serve AerServ banner, interstitial, and virtual currency (VC) interstitial ads through AdMob SDK.
Important Notes
- If you want to enable banner refresh, you should only do so with one SDK. Having refresh on both SDKs will result in duplicate requests. We recommend that you enable it for AdMob and disable it for AerServ.
- For banners, ensure that the ad size you request from AdMob SDK is the same size as what AerMarket would return. E.g. if AerMarket's ad is 320x50, the banner size for your AdMob's ad request would be BANNER.
Step 1: Download iOS SDK and Required Adapter Files
Download latest AerServ iOS SDK here. The downloaded ZIP file contains both the SDK library and adapter files.
Step 2: Configure Your Project
- Follow AdMob’s instructions on setting up their SDK for your project.
- Unzip the downloaded SDK package file and copy the
AerServSDK.framework
found at the pathtarget/aerserv-ios-sdk/lib/
into your Xcode project. - Add both the header and implementation file for
AerServCustomEventBanner
,AerServCustomEventInterstitial
,AerServCustomEventRewardInterstitial
,AerServUtils
,AerServExtras
andAerServExceptions
into your project. - In the General tab inside your project’s setting, add the following to Linked Frameworks and Libraries
AerServSDK.framework
Webkit.framework
libxml2.2.tbd
- Next go to Build Settings and add the following configuration:
- Add the linker flag -ObjC to the "Other Linker Flags" field inside the Linking section.
- Add the directory path to the
AerServSDK.framework
to “Framework Search Paths" inside the Search Paths section; select it as recursive.
- In your AppDelegate, add #import <AerServSDK/AerSerSDK.h>. Initialize the AerServSDK inside application:didiFinishLaunchingWithOptions.
[AerServSDK initializeWithAppID:@"YOUR APPID"]
- To set or update the General Data Protection Regulation (GDPR) user consent flag, call AerServSDK’s +setGDPRWithUserConsent: method. Pass YES/true for user consent if GDPR user consent was granted and NO/false if user consent was denied or if unknown. To have the GDPR user consent flag to be set before an ad request, call +setGDPRWithUserConsent: before calling -loadAd. It is not necessary to reset the user consent value prior to each ad request; the value set is applicable for all subsequent requests until that value is reset.
// Replace YES with the actual consent value of user consent.
[AerServSDK setGDPRWithUserConsent:YES];
Step 3: Configure Ad Settings on AerServ Web Interface
- Follow instruction to set up AerServ Placements and Ad Sources.
- For banner ads, please set refresh interval to Never. If you want banner refresh, enable it with AdMob instead.
Step 4: Configure Ad Settings on AdMob Web Interface
- If you have not done so already, follow instructions from AdMob and add your app and ad units.
- Go to Monetize tab, and find and click on your app from the panel on your left. You should see a table listing ad units you currently have.
- Find the ad unit you wish to mediate to AerServ. Click on link under Mediation column.
- Click + NEW AD NETWORK button, then on the following page click on + CUSTOM EVENT button.
- Enter the following information:
- Class Name: AerServCustomEventBanner for banner, and AerServCustomEventInterstitial for interstitial, and AerServCustomEventRewardedInterstitial for rewarded videos
- Label: See AdMob's instructions
- Parameter: AerServ ad parameters, in JSON format. This field will take any additional parameter for the AerServ SDK. Refer to Advance Topics - Server Parameters for more information.
- OR -
Step 4: Configure Ad Settings on AdMob BETA's Web Interface
- If you have not done so already, follow instructions from AdMob and add your app and ad units.
- Go to the Mediation page with the sidebar.
- This will bring you to the Mediation Group tab within the Mediation page. Here you can either create a new mediation group or use an existing one.
- If you are using an existing “Mediation Group” simply click on the Mediation Group name and skip this step.
- Click on CREATE NEW MEDIATION GROUP
- Select the corresponding Ad Format and Platform that will be used in the mediation.
- Fill in the “Mediation Group Name” field. This will not affect your mediation setup and any name can use.
- Click on Add Ad Unit and add the Ad Unit that will be mediating to AerServ.
- Click on Add Custom Event
- Fill in the Label field. This will not affect your mediation setup and any name can use.
- Fill in the eCPM. You can find this in the AerServ dashboard under Reporting.
- Click continue.
- Enter the following information:
- Class Name: Use one of the following class name. If you changed the package name, please change the classpath to correspond with the new package name.
- AerServCustomEventBanner for banner
- AerServCustomEventInterstitial for interstitial
- AerServCustomEventRewardedInterstitial for rewarded videos
- Parameter: AerServ ad parameters, in JSON format. This field will take any additional parameter for the AerServ SDK. Refer to Advance Topics - Server Parameters for more information.
- Click on Done.
- Click on Save and you’re done.
Step 5: Request Ads
Follow AdMob's instructions to request banner, interstitial, or rewarded video ads, but using ad units that you created in Step 3 above. There are no different or special API calls to fetch AerMarket ads, as all mediation is done automatically for you by the adapters.
Advanced Topics
Server Parameter
AerServ server ad parameter that you entered on AdMob's web interface must be in JSON format. Currently we support this parameter:
NAME | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
---|---|---|---|---|
placement |
String |
Yes |
N/A |
AerServ Placement |
Here is a sample value:
{
"placement":"1000741",
}
Event Mapping
AerServ banner events are mapped to AdMob's CustomEventBannerDelegate events, as follows:
adViewDidLoadAd → customEventBanner
adViewDidFailToLoadAd → adViewDidFailToLoadAd
willPresentModalViewForAd → customEventBannerWillPresentModal
willLeaveApplicatonFromAd → customEventBannerWillLeaveApplication
adWasClicked → customEventBannerWasClicked & customEventBannerWillLeaveApplication
didDismissModalViewForAd → customEventBannerDidDismissModal
AerServ interstitial events are mapped to AdMob's CustomEventInterstitialDelegate events, as follows:
interstitialViewControllerDidPreloadAd → customEventInterstitialDidReceiveAd
interstitialViewControllerAdFailedToLoad → interstitialViewControllerAdFailedToLoad
interstitialViewControllerWillDisappear → customEventInterstitialWillDismiss
interstitialViewControllerDidDisappear → customEventInterstitialDidDismiss
interstitialViewControllerWillAppear → customEventInterstitialWillPresent
interstitialViewControllerAdWasTouched → customEventInterstitialWasClicked & customEventInterstitialWillLeaveApplication
AerServ rewarded video events are mapped to AdMob’s GADRewardBasedVideoAdNetworkAdapterProtocol events, as follows:
interstitialViewControllerDidPreloadAd → adapterDidRecieveRewardBasedVideoAd
interstitialViewControllerAdFailedToLoad → didFailToLoadRewardBasedVideoAdwithError
interstitialViewControllerDidDisappear → adapterDidCloseRewardBasedVideoAd
interstitialViewControllerDidAppear → adapterDidOpenRewardBasedVideoAd
interstitialViewControllerAdWasTouched → adapterDidGetAdClick & adapterWillLeaveApplication
interstitialViewControllerDidVirtualCurrencyReward → didRewardUserWithReward
Error Codes
AerServ adapter will fire the following AdMob errors using their AdRequest error enum:
ADREQUEST ENUM | CONDITION |
---|---|
kGADErrorInvalidRequest |
|
kGADErrorMediationNoFill |
AerServ SDK fired AD_FAILED event. See AerServ SDK documentation for more details. |
User ID
If you use AerServ's server URL callback virtual currency reward mechanism, you might need to programmatically pass in user ID. You can do so through AdMob, as follows:
GADRequest *request = [GADRequest request];
AerservExtras *aerservExtra = [[AerservExtras alloc] init];
aerservExtra.userId = @"MyUserId";
[request registerAdNetworkExtras:aerservExtra];
This adapter allows you to serve AerServ banner, interstitial, and virtual currency (VC) interstitial ads through AdMob SDK.
Important Notes
- If you want to enable banner refresh, you should only do so with one SDK. Having refresh on both SDKs will result in duplicate requests. We recommend that you enable it for AdMob and disable it for AerServ.
- For banners, ensure that the ad size you request from AdMob SDK is the same size as what AerMarket would return. E.g. if AerMarket's ad is 320x50, the banner size for your AdMob's ad request would be BANNER. In addition, if your AerServ ad source mediates to Millennial Media, make sure your AdMob's AdView has specific width and height (instead of just "wrap_content"), as Millennial Media's banners tend to occupy the entire screen size if the dimensions are not specified.
- If you use AdMob's rewarded APIs for ad requests, you must also enable VC with AerServ. AerServ uses BigDecimal as reward amount (which is a decimal, and has no limit), while AdMob uses int (with is an integer with maximum value of 2^32). If AerServ's amount value is too big to fit in int, no reward will be given. Also, if AerServ amount contains decimal value, it will be rounded to the nearest whole number.
Step 1: Download Android SDK and Required Adapter Files
Download latest AerServ Android SDK here. The downloaded ZIP file contains both the SDK library and adapter files.
Step 2: Configure Your Project
- Follow AdMob's instructions on setting up their SDK for your project
- Unzip AerServ SDK ZIP file, and copy
aerserv-android-sdk/lib/aerserv-sdk.jar
into your project's libs folder. - Copy all Java files from
aerserv-android-sdk/network-support/AdMob
into your project's source folder. These adapter files have com.aerserv.admob as package name. You can either put them in the corresponding destination folder, or you can change the package name at the top of each adapter file. - Add permissions and activity declarations to your AndroidManifest.xml.
<!-- Required. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Optional. Excluding these can negatively affect fill rate. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Optional. If excluded, ads will not be cached. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...
<application>
... <activity
android:name="com.aerserv.sdk.view.AerServFullScreenAdActivity"
android:theme="@android:style/Theme.Translucent"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
android:name="com.aerserv.sdk.view.ASVastInterstitialActivity"
android:theme="@android:style/Theme.Translucent"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity android:name="com.aerserv.sdk.view.ASWebviewInterstitialActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity android:name="com.aerserv.sdk.view.ASVpaidInterstitalActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:hardwareAccelerated="true" /> </application> - You must initialize our SDK before loading any ads. We recommend that you invoke this initialization routine at least 10 seconds before you intend to show your first ad (a good location would be your main activity's onCreate() method).
To initialize the SDK, invoke the following:
AerServSdk.init(MainActivity.this, MY_APP_ID);
How to obtain the app ID:
- Log on to the AerServ platform.
- Go to the 'Inventory' tab in the top navigation bar.
- Click the 'Edit' icon next to the app whose ID you wish to obtain.
- You will find the app ID at the very top of the page.
-
To set or update the General Data Protection Regulation (GDPR) user consent flag, call AerServSDK’s setGdprConsentFlag method. Pass true for user consent if GDPR user consent was granted and false if user consent was denied or if unknown. To have the GDPR user consent flag be set prior to an ad request, call the setGdprConsentFlag method before requesting an ad. The value passed into setGdprConsentFlag will persist as a private value within Android’s SharedPreferences. Thus, it is not necessary to reset the user consent value prior to each ad request; the value set is applicable for all subsequent requests until that value is reset.
AerServSdk.setGdprConsentFlag((Activity) MY_ACTIVITY, (boolean) true);
Step 3: Configure Ad Settings on AerServ Web Interface
- Follow instruction to set up AerServ Placements and Ad Sources.
- For banner ads, please set refresh interval to Never. If you want banner refresh, enable it with AdMob instead.
Step 4: Configure Ad Settings on AdMob Web Interface
- If you have not done so already, follow instructions from AdMob and add your app and ad units.
- Go to Monetize tab, and find and click on your app from the panel on your left. You should see a table listing ad units you currently have.
- Find the ad unit you wish to mediate to AerServ. Click on link under Mediation column.
- Click + NEW AD NETWORK button, then on the following page click on + CUSTOM EVENT button.
- Enter the following information:
- Class Name: com.aerserv.admob.AerServCustomEventBanner for banner, and com.aerserv.admob.AerServCustomEventInterstitial for interstitial, and com.aerserv.admob.AerServCustomEventRewardedInterstitial for rewarded videos. If you changed the package name, please use the new name instead.
- Label: See AdMob's instructions
- Parameter: AerServ ad parameters, in JSON format. The only required parameter is placement, which must be a string. Here is an example:
{"placement":"1000741"}
- OR -
Step 4: Configure Ad Settings on AdMob BETA's Web Interface
- If you have not done so already, follow instructions from AdMob and add your app and ad units.
- Go to the Mediation page with the sidebar.
- This will bring you to the Mediation Group tab within the Mediation page. Here you can either create a new mediation group or use an existing one.
- If you are using an existing “Mediation Group” simply click on the Mediation Group name and skip this step.
- Click on CREATE NEW MEDIATION GROUP
- Select the corresponding Ad Format and Platform that will be used in the mediation.
- Fill in the “Mediation Group Name” field. This will not affect your mediation setup and any name can use.
- Click on Add Ad Unit and add the Ad Unit that will be mediating to AerServ.
- Click on Add Custom Event
- Fill in the Label field. This will not affect your mediation setup and any name can use.
- Fill in the eCPM. You can find this in the AerServ dashboard under Reporting.
- Click continue.
- Enter the following information:
- Class Name: Use one of the following class name. If you changed the package name, please change the classpath to correspond with the new package name.
- com.aerserv.admob.AerServCustomEventBanner for banner
- com.aerserv.admob.AerServCustomEventInterstitial for interstitial
- com.aerserv.admob.AerServCustomEventRewardedInterstitial for rewarded videos
- Parameter: AerServ ad parameters, in JSON format. This field will take any additional parameter for the AerServ SDK. Refer to Advance Topics - Server Parameters for more information.
- Click on Done.
- Click on Save and you’re done.
Step 5: Request Ads
Follow AdMob's instructions to request banner, interstitial, or rewarded video ads, but using ad units that you created in Step 3 above. There are no different or special API calls to fetch AerMarket ads, as all mediation is done automatically for you by the adapters.
Advanced Topics
Server Parameter
AerServ server ad parameter must be in JSON format. Currently we support this parameter:
NAME | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
---|---|---|---|---|
placement |
String |
Yes |
N/A |
AerServ Placement |
Here is a sample value:
{
"placement":"1000741",
}
Event Mapping
AerServ banner events are mapped to AdMob's CustomEventBannerListener events, as follows:
AD_LOADED → onAdLoaded()
AD_FAILED → onAdFailed()
AD_CLICKED → onAdClicked()
AD_DISMISSED → onAdCollapsed()
AerServ interstitial events are mapped to AdMob's CustomEventInterstitialListener events, as follows:
PRELOAD_READY → onAdLoaded()
AD_FAILED → onAdFailed()
AD_CLICKED → onAdClicked()
AD_IMPRESSION → onAdExpanded()
AD_DISMISSED → onAdCollapsed()
AerServ VC-enabled interstitial events are mapped to AdMob's MediationRewardedVideoAdListener events, as follows:
PRELOAD_READY → onAdLoaded()
AD_IMPRESSION → onAdOpened()
VIDEO_START → onVideoStarted()
AD_DISMISSED → onAdClosed()
VC_REWARDED → onRewarded()
AD_CLICKED → onAdClicked()
AD_FAILED → onAdFailedToLoad()
Error Codes
AerServ adapter will fire the following AdMob errors using their AdRequest error enum:
ADREQUEST ENUM | CONDITION |
---|---|
ERROR_CODE_INVALID_REQUEST |
|
ERROR_CODE_NO_FILL |
AerServ SDK fired AD_FAILED event. See AerServ SDK documentation for more details. |
User ID
If you use AerServ's server URL callback virtual currency reward mechanism, you might need to programmatically pass in user ID. You can do so through AdMob, as follows:
Bundle bundle = new Bundle();
bundle.putString("userId", "MyUserId");
AdRequest adRequest = new AdRequest.Builder().addNetworkExtrasBundle(
AerServCustomEventRewardedInterstitial.class, bundle).build();
Comments