Follow

AppNexus Plugin Integration

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 AppNexus and disable it for AerServ.

 

 

 

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 AppNexus’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 and AerServUtils into your project.
      4. In the General tab inside your project’s settingl, 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 <AerSerSDK/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 AppNexus instead.

 

Step 4: Configure Ad Settings on AppNexus Web Interface

    1. If you have not done so already, follow instructions from AppNexus and add your app and ad units.
    2. Create a “Custom Mobile Network Bid” with the following information:
      • Device Class Name: AerServCustomEventBanner for banner and AerServCustomEventInterstitial for interstitial.
      • Network Id: This is equivalent to “placement” on the AerServ Ad network.
      • Network 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.

 

Step 5: Configure Ad Settings on AppNexus Web Interface

Follow AppNexus instructions to request banner or interstitial, 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


 

Event Mapping

AerServ banner events are mapped to AppNexus’s CustomEventBannerListener events, as follows:

adViewDidLoadAddidLoadBannerAd

adViewDidFailToLoadAddidFailToLoadAd

willPresentModalViewForAdwillPresentAd

willLeaveApplicatonFromAdwillLeaveApplication

adWasClickedadWasClicked

didDismissModalViewForAddidCloseAd

 

AerServ interstitial events are mapped to AppNexus’s CustomEventInterstitialListener events, as follows:

interstitialViewControllerDidPreloadAddidLoadInterstitialAd

interstitialViewControllerAdFailedToLoaddidFailToLoadAd

interstitialViewControllerDidDisappeardidCloseAd

interstitialViewControllerWillAppearwillPresentAd

interstitialViewControllerDidAppeardidPresentAd

interstitialViewControllerAdWasTouchedadWasClicked

 

Error Codes

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

ADREQUEST ENUM CONDITION

ANAdResponseInvalidRequest

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

ANAdResponseUnableToFill

AerServ SDK fired AD_FAILED event.  See AerServ SDK documentation for more details.

  

 

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 AppNexus'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/AppNexus into your project's source folder. These adapter files have com.aerserv.appnexus 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 the following permissions AndroidManifest.xml: 
          <uses-permission android:name="android.permission.INTERNET" />
          <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" />
          <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
          <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        • Add the following activities AndroidManifest.xml:
          
          <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" />
  4. You must initialize our SDK.  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.
  5. 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 AppNexus instead.

 

Step 4: Configure Ad Settings on AppNexus Web Interface

        1. If you have not done so already, follow instructions from AppNexus and add your app and ad units.
        2. Create a “Custom Mobile Network Bid” with the following information:
            • Device Class Name: com.aerserv.appnexus.AerServCustomEventBanner for banner, com.aerserv.appnexus.AerServCustomEventInterstitial for interstitial.
            • Network Id: This is equivalent to “placement” on the AerServ Ad network.
            • Network Parameter: AerServ ad parameters, in JSON format. This field will take any additional parameter for the AerServ SDK. Refer to Advanced Topics - Server Parameters of this article for more information.

 

Step 5: Request Ads

Follow AppNexus instructions to request banner or interstitial, 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



Event Mapping

AerServ banner events are mapped to AppNexus's CustomEventBannerListener events, as follows:

AD_FAILEDonAdFailed()

AD_CLICKEDonAdClicked()

AD_LOADEDonAdLoaded()

AD_IMPRESSIONonAdExpanded()

 

* Note: onAdLoaded() is fired during the ad request for banner due to a issue with the banner sizing.

 

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

PRELOAD_READYonAdLoaded()

AD_FAILEDonAdFailed()

AD_CLICKEDonAdClicked()

AD_IMPRESSIONonAdExpanded()

AD_DISMISSEDonAdCollapsed()


Error Codes

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


ADREQUEST ENUM CONDITION

INVALID_REQUEST

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

UNABLE_TO_FILL

AerServ SDK fired AD_FAILED event.  See AerServ SDK documentation for more details.

 

 

Limitations:

The AppNexus Plugin has a limitation on rendering AdMob and Millennial Media banner due to one of the checks do for banners and how AppNexus SDK is design. As such, for AdMob and Millennial Media mediation, please do this through AppNexus.

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

Comments