Follow

AdMob Plugin Integration

 

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

  1. Follow AdMob’s instructions on setting up their SDK for your project.
  2. Unzip the downloaded SDK package file and copy the AerServSDK.framework found at the path target/aerserv-ios-sdk/lib/ into your Xcode project.
  3. Add both the header and implementation file for AerServCustomEventBanner, AerServCustomEventInterstitial, AerServCustomEventRewardInterstitial, AerServUtils, AerServExtras and AerServExceptions into your project.
  4. In the General tab inside your project’s setting, add the following to Linked Frameworks and Libraries
      • AerServSDK.framework
      • Webkit.framework
      • libxml2.2.tbd
  5. 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.
  6. In your AppDelegate, add #import <AerServSDK/AerSerSDK.h>. Initialize the AerServSDK inside application:didiFinishLaunchingWithOptions.

    [AerServSDK initializeWithAppID:@"YOUR APPID"]

  7. 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

    1. Follow instruction to set up AerServ Placements and Ad Sources.
    2. 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

    1. If you have not done so already, follow instructions from AdMob and add your app and ad units.
    2. 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.
    3. Find the ad unit you wish to mediate to AerServ. Click on link under Mediation column.
    4. Click + NEW AD NETWORK button, then on the following page click on + CUSTOM EVENT button.
    5. 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

  1. If you have not done so already, follow instructions from AdMob and add your app and ad units.
  2. Go to the Mediation page with the sidebar.
  3. 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.
  4. If you are using an existing “Mediation Group” simply click on the Mediation Group name and skip this step.
    1. Click on CREATE NEW MEDIATION GROUP
    2. Select the corresponding Ad Format and Platform that will be used in the mediation.
    3. Fill in the “Mediation Group Name” field. This will not affect your mediation setup and any name can use.
    4. Click on Add Ad Unit and add the Ad Unit that will be mediating to AerServ.
  5. Click on Add Custom Event
    1. Fill in the Label field. This will not affect your mediation setup and any name can use.
    2. Fill in the eCPM. You can find this in the AerServ dashboard under Reporting.
    3. Click continue.
  6. Enter the following information:
    1. 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.  
      1. AerServCustomEventBanner for banner
      2. AerServCustomEventInterstitial for interstitial
      3. AerServCustomEventRewardedInterstitial for rewarded videos
    2. 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.
  7. Click on Done.
  8. 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

  • Invalid server parameter JSON
  • Missing placement value
  • Context passed into adapter is not of type Activity

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

    1. Follow AdMob's instructions on setting up their SDK for your project
    2. Unzip AerServ SDK ZIP file, and copy aerserv-android-sdk/lib/aerserv-sdk.jar into your project's libs folder.
    3. 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.
    4. 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>

       

    5. 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:

        1. Log on to the AerServ platform.
        2. Go to the 'Inventory' tab in the top navigation bar.
        3. Click the 'Edit' icon next to the app whose ID you wish to obtain.
        4. You will find the app ID at the very top of the page.
    6. 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

    1. Follow instruction to set up AerServ Placements and Ad Sources.
    2. 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

    1. If you have not done so already, follow instructions from AdMob and add your app and ad units.
    2. 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.
    3. Find the ad unit you wish to mediate to AerServ. Click on link under Mediation column.
    4. Click + NEW AD NETWORK button, then on the following page click on + CUSTOM EVENT button.
    5. 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

  1. If you have not done so already, follow instructions from AdMob and add your app and ad units.
  2. Go to the Mediation page with the sidebar.
  3. 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.
  4. If you are using an existing “Mediation Group” simply click on the Mediation Group name and skip this step.
    1. Click on CREATE NEW MEDIATION GROUP
    2. Select the corresponding Ad Format and Platform that will be used in the mediation.
    3. Fill in the “Mediation Group Name” field. This will not affect your mediation setup and any name can use.
    4. Click on Add Ad Unit and add the Ad Unit that will be mediating to AerServ.
  5. Click on Add Custom Event
    1. Fill in the Label field. This will not affect your mediation setup and any name can use.
    2. Fill in the eCPM. You can find this in the AerServ dashboard under Reporting.
    3. Click continue.
  6. Enter the following information:
    1. 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.  
      1. com.aerserv.admob.AerServCustomEventBanner for banner
      2. com.aerserv.admob.AerServCustomEventInterstitial for interstitial
      3. com.aerserv.admob.AerServCustomEventRewardedInterstitial for rewarded videos
    2. 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.
  7. Click on Done.
  8. 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_LOADEDonAdLoaded()

AD_FAILEDonAdFailed()

AD_CLICKEDonAdClicked()

AD_DISMISSEDonAdCollapsed()

AerServ interstitial events are mapped to AdMob's CustomEventInterstitialListener events, as follows:

PRELOAD_READYonAdLoaded()

AD_FAILEDonAdFailed()

AD_CLICKEDonAdClicked()

AD_IMPRESSIONonAdExpanded()

AD_DISMISSEDonAdCollapsed()

 

AerServ VC-enabled interstitial events are mapped to AdMob's MediationRewardedVideoAdListener events, as follows:

PRELOAD_READYonAdLoaded()

AD_IMPRESSIONonAdOpened()

VIDEO_STARTonVideoStarted()

AD_DISMISSEDonAdClosed()

VC_REWARDEDonRewarded()

AD_CLICKEDonAdClicked()

AD_FAILEDonAdFailedToLoad()

 

Error Codes

AerServ adapter will fire the following AdMob errors using their AdRequest error enum:

ADREQUEST ENUM CONDITION

ERROR_CODE_INVALID_REQUEST

  • Invalid server parameter JSON
  • Missing placement value
  • Context passed into adapter is not of type Activity

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();

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments