Integrate with AdMob

If you already have AdMob ads serving in your app, but want to integrate AwesomeAds as well, without having to directly use the iOS Publisher SDK, you can follow the steps below:

Add the AdMob plugin

Change your Podfile to contain the following:

target 'MyProject' do
    # add the SuperAwesome SDK
    pod 'SuperAwesome', '~> 7.2'

    # add the AdMob plugin
   pod 'SuperAwesomeAdMob', '~> 7.2'
end

and execute

pod update

Setup AdMob Mediation Groups

Login to the AdMob dashboard using your preferred account.

From here forward the tutorial assumes you have an iOS app with three ad units setup in AdMob; one banner, one interstitial ad and one rewarded video ad:

image-title-here

Then, in the Mediation menu, create a new Mediation Group:

image-title-here

Next, fill in the necessary details:

image-title-here

and add your app’s banner Ad Unit as target:

image-title-here

Then, in the Ad Sources panel, add a new Custom Event:

image-title-here

and, as well, customise it:

image-title-here

and finally set the AwesomeAds custom event class name as Class Name SAAdMobBannerCustomEvent and the parameter as your Placement ID:

image-title-here

Notice that the custom event class names required by AdMob are:

  • for Banner Ads:

SAAdMobBannerCustomEvent

  • for Interstitial Ads:

SAAdMobInterstitialCustomEvent

  • for Rewarded Video Ads:

SAAdMobVideoMediationAdapter

Finally, save your changes. This will register BannerCustomEvent as a custom event running on your ad units from now on. You’ll have to repeat the same process for interstitial and rewarded video ads.

Implement Ads

Once the previous steps are done, you can add AdMob banners, interstitials and rewarded video ads just as you normally would:

// 1.1 create a banner request
GADRequest *bannerReq = [GADRequest request];

// 1.2. add banner view
GADBannerView *banner = [[GADBannerView alloc] initWithAdSize: kGADAdSizeBanner];
banner.adUnitID = @"__YOUR_ADMOB_UNIT_ID__";
banner.rootViewController = self;
[self.view addSubview: banner];
[banner loadRequest: bannerReq];

// 2.1. create an interstitial request
GADRequest *interstitialReq = [GADRequest request];

// 2.2. add an interstitial
GADInterstitial *interstitial = [[GADInterstitial alloc]
        initWithAdUnitID: @"__YOUR_ADMOB_UNIT_ID__"];
[self.interstitial loadRequest: interstitialReq];

// 3.1. create a rewarded video request
GADRequest *videoReq = [GADRequest request];

// 3.2. add rewarded video
[[GADRewardBasedVideoAd sharedInstance] loadRequest: videoReq
        withAdUnitID: @"__YOUR_ADMOB_UNIT_ID__"];

Since the previously created custom events will run on these ads, and AwesomeAds is integrated alongside the AdMob plugin, you should start seeing ads playing.

Customise the Experience

Additionally, you can customize the experience of each ad unit.

  1. For banners:
// First, create an options object where you set the parameters that
// normally affect an AwesomeAds banner ad
SAAdMobCustomEventExtra *options = [[SAAdMobCustomEventExtra alloc] init];
options.testEnabled = false;
options.parentalGateEnabled = true;
options.trasparentEnabled = true;

// then create a standard GADCustomEventExtras object
GADCustomEventExtras *extra = [GADCustomEventExtras new];

// and assign to it the options object created above
// note that the label you add the options object for has to be
// the same as the name of the custom mediation event you created
[extra setExtras: options forLabel: @"BannerCustomEvent"];

// finally register the GADCustomEventExtras object with the request
[bannerReq registerAdNetworkExtras: extra];
  1. For interstitials:
// First, create an options object where you set the parameters that
// normally affect an AwesomeAds interstitial ad
SAAdMobCustomEventExtra *options = [[SAAdMobCustomEventExtra alloc] init];
options.testEnabled = false;
options.parentalGateEnabled = true;
options.orientation = PORTRAIT;

// then create a standard GADCustomEventExtras object
GADCustomEventExtras *extra = [GADCustomEventExtras new];

// and assign to it the options object created above
// note that the label you add the options object for has to be
// the same as the name of the custom mediation event you created
[extra setExtras: options forLabel:@"InterstitialCustomEvent"];

// finally register the GADCustomEventExtras object with the request
[interstitialReq registerAdNetworkExtras: extra];
  1. For rewarded video:
// First, create an options object where you set all the parameters that
// normally affect an AwesomeAds video ad
SAAdMobVideoExtra *options = [[SAAdMobVideoExtra alloc] init];
options.testEnabled = false;
options.closeAtEndEnabled = true;
options.closeButtonEnabled = false;
options.parentalGateEnabled = false;
options.smallCLickEnabled = true;
options.orientation = LANDSCAPE;

// For video, just register the options object with the request directly
[videoReq registerAdNetworkExtras: options];

These parameters will be passed by the AdMob SDK to the AwesomeAds Plugin so that ads will display the way you want them to.