Adapter for DFP Mobile Ads SDK for iOS

Follow this guide to add Media.Net iOS SDK to DFP mediation layer. The Media.Net adapter allows the inclusion of Media.Net ads in DFP mediation.

Go through the steps in our Getting Started Guide to add Media.Net SDK to your project before starting the adapter integration.

Overview of DFP Adapter Mediation

In this configuration, your application talks to the DFP SDK, which in turn requests content from the Media.Net SDK. See below diagram of the flow of information from Media.Net - DFP adapter mediation:

Media.Net SDK Instructions

Requirements:

  • Media.Net SDK
  • DFP SDK (The minimum version tested is 9.6.1)

Before Getting Started:

  • Make sure that your app has the DFP SDK and is registered in your DFP account.
  • Your app has configured the Banner and/or interstitial Ad Units.
  • You have read through DFP getting started guide for iOS.
  • You have the Media.Net dashboard account and ‘Customer ID’ for the app where you want to run ads.

Integrating Media.Net Adapter into your iOS App

Add the following line to your project’s podfile:

pod 'MNetAdSdk', :git=> 'https://github.com/media-net/mnet-ad-sdk', :tag=> '1.0.0'

Media.Net Network Setup in DFP

Follow the instructions below to add MNet as an Ad Network through DFP dashboard:

1) Click on Delivery from the menu bar on the top of your DFP account dashboard. Then select Yield groups from the list of menu on the left.

2) In the next screen click on CREATE YIELD GROUP if you don’t have already created one. Follow the guide here to add a mediation group.

3) Once the mediation group is created, click on the down arrow for the mediation group as shown in the figure below.

4) From the following screen click on EDIT.

5) In the following screen click on ADD ANOTHER YIELD PARTNER.

6) Next from the drop down for Mediation Network, select Create a new mediation network.

7) In the popup screen, search for other network from the Ad network dropdown. Then add your prefered name for MNet ads network and click save.

8) You will then have to select the Operating system from the drop down. Then fill in the Class Name and Parameter fields which will be provided to you by your MNet account manager.

Passing custom data through DFP Mediation Adapter

Custom data like user-details, location-details and context-link can be sent into the DFPRequest object, through certain paramaters, which will be picked up by the MNet ad-views to contextualize the mediation-ads.

NOTE: this process is equivalent in both Banner and Interstitial ads.

Here is an example for setting the user and Location details in the DFPRequest object-

Objective-C

DFPRequest *request = [DFPRequest request];

// User-related details
[request setGender:kGADGenderFemale];
[request setBirthday:[NSDate dateWithTimeIntervalSince1970:0]];

// Location-related details
[request setLocationWithLatitude:LATITUDE
                       longitude:LONGITUDE
                        accuracy:LOCATION_ACCURACY];

Swift

let request:DFPRequest = DFPRequest.init()

// User-related details
request.gender = .female

var dateComponents = DateComponents()
dateComponents.month = 1
dateComponents.day = 1
dateComponents.year = 1970
request.birthday = Calendar.current.date(from: dateComponents)

// Location related details
request.setLocationWithLatitude(CGFloat(currentLocation.coordinate.latitude)
                , longitude: CGFloat(currentLocation.coordinate.latitude),
                  accuracy:  CGFloat(currentLocation.horizontalAccuracy))

Context-link can be intimated to MNet in a couple of ways. Through keywords and GADCustomEventExtras. Note that if both of these are set, then the context-link in keywords takes precedence.

Both of these are illustrated below- To send the context_link in keywords, just add a key-value pair string entry to the NSArray separated by a colon(:), with the key being content_link and the value being the context-link.

Objective-C

[request setKeywords:@[
    @"content_link:https://my-custom-link.com/keywords"
]];

Swift

request.keywords = [
    "content_link:https://my-custom-link.com/keywords"
];

To send the context-link in GADCustomEventExtras, add the key-value pair in the extras dictionary, with the key as content_link and the value being the actual context-link.

NOTE: Make sure that the label(DFP_CUSTOM_EVENT_LABEL in the example below) for which the extras are set is consistent with the label in DFP’s dashboard.

Objective-C

GADCustomEventExtras *customEventExtras = [[GADCustomEventExtras alloc] init];
[customEventExtras setExtras:@{
                               @"content_link": @"https://my-custom-link.com/additional_params",
                           }
                    forLabel:DFP_CUSTOM_EVENT_LABEL]
[request registerAdNetworkExtras:customEventExtras];
Swift
let customEventExtras = GADCustomEventExtras.init()
customEventExtras.setExtras([
    "content_link": "https://my-custom-link.com/additional_params",
    ], forLabel: DFP_CUSTOM_EVENT_LABEL)
request.adNetworkExtras(for: customEventExtras)