Integrate with AdMob
If you already have AdMob ads serving in your app, you can integrate AwesomeAds without having to use the AwesomeAds Publisher SDK directly.
Add the AdMob plugin
- In Xcode, go to File → Add Package Dependencies…
- Enter the following package URL:
https://github.com/superawesome-org/sa-mobile-sdk-ios-spm - Set the version rule to Up to Next Major Version with a minimum of
10.1.0. - Click Add Package and select both the
SuperAwesomeandSuperAwesomeAdMoblibraries to add to your target.
Set up iOS AdMob Mediation Groups
Next, you need to set up a Mediation Group for each type of AdMob ad that you wish to display: banner, interstitial, and video.
- Log in to the AdMob dashboard.
-
For this tutorial, assume you have set up an iOS app with three ad units in AdMob: one banner ad, one interstitial ad, and one rewarded video ad:

-
In the Mediation menu, create a new iOS Mediation Group:

-
Enter the Mediation Group details:

-
Add your app’s banner Ad Unit as target:

-
In the Ad Sources panel, add a new Custom Event:


- Customize the Custom Event:

- Class Name:
SAAdMobAdapter - Parameter: This is your
placementId
You should now have at least two different ad sources. Save your changes.
Finally, save your changes. This will register a custom banner event. You’ll have to repeat the same process for interstitial and rewarded video ads.
Implement AdMob ads
After you set up the AdMob Mediation Groups, you can add AdMob banners, interstitials, and rewarded video ads as normal:
Add an AdMob banner
- Create the banner request:
let bannerReq = GoogleMobileAds.Request()
GADRequest *bannerReq = [GADRequest request];
- Add the banner view:
let banner = GoogleMobileAds.BannerView(adSize: GADAdSizeBanner)
banner.adUnitID = "__YOUR_ADMOB_UNIT_ID__"
banner.rootViewController = self
view.addSubview(banner)
banner.load(bannerReq)
GADBannerView *banner = [[GADBannerView alloc] initWithAdSize: GADAdSizeBanner];
banner.adUnitID = @"__YOUR_ADMOB_UNIT_ID__";
banner.rootViewController = self;
[self.view addSubview: banner];
[banner loadRequest: bannerReq];
Add an AdMob interstitial ad
- Create the interstitial request:
let interstitialReq = GoogleMobileAds.Request()
GADRequest *interstitialReq = [GADRequest request];
- Add the interstitial ad:
var ad: GoogleMobileAds.InterstitialAd?
GoogleMobileAds.InterstitialAd.load(with: "__YOUR_ADMOB_UNIT_ID__",
request: interstitialReq) { interstitialAd, error in
if let error = error {
print("Failed to load interstitial ad with error: \(error.localizedDescription)")
return
}
ad = interstitialAd
print("Interstitial ad loaded.")
}
__block GADInterstitialAd *ad;
[GADInterstitialAd loadWithAdUnitID:@"__YOUR_ADMOB_UNIT_ID__"
request:interstitialReq
completionHandler:^(GADInterstitialAd * _Nullable interstitialAd, NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to load interstitial ad with error: %@", error.localizedDescription);
return;
}
ad = interstitialAd;
NSLog(@"Interstitial ad loaded.");
}];
Add an AdMob rewarded video ad
- Create the rewarded video request:
let videoReq = GoogleMobileAds.Request()
GADRequest *videoReq = [GADRequest request];
- Add the rewarded video ad:
var ad: GoogleMobileAds.RewardedAd?
GoogleMobileAds.RewardedAd.load(with: "__YOUR_ADMOB_UNIT_ID__",
request: videoReq) { rewardedAd, error in
if let error = error {
print("Failed to load rewarded ad with error: \(error.localizedDescription)")
return
}
ad = rewardedAd
print("Rewarded ad loaded.")
}
__block GADRewardedAd *ad;
[GADRewardedAd loadWithAdUnitID:@"__YOUR_ADMOB_UNIT_ID__"
request:videoReq
completionHandler:^(GADRewardedAd * _Nullable rewardedAd, NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to load rewarded ad with error: %@", error.localizedDescription);
return;
}
ad = rewardedAd;
NSLog(@"Rewarded ad loaded.");
}];
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.
Customize the experience
You can customize the experience of each ad unit by creating an SAAdMobExtras object that sets the ad parameters. The AdMob adapter passes these parameters to the AwesomeAds SDK so that the ads display the way you want them to.
Note: Not all properties apply to all ad formats. Properties that are not supported for a given format are silently ignored.
Customize a banner ad
Supported properties: testEnabled, parentalGateEnabled, bumperPageEnabled, trasparentEnabled
let extras = SAAdMobExtras()
extras.testEnabled = false
extras.parentalGateEnabled = true
extras.trasparentEnabled = true
let bannerReq = GoogleMobileAds.Request()
bannerReq.register(extras)
SAAdMobExtras *extras = [[SAAdMobExtras alloc] init];
extras.testEnabled = false;
extras.parentalGateEnabled = true;
extras.trasparentEnabled = true;
GADRequest *bannerReq = [GADRequest request];
[bannerReq registerAdNetworkExtras:extras];
Customize an interstitial ad
Supported properties: testEnabled, parentalGateEnabled, bumperPageEnabled, orientation
let extras = SAAdMobExtras()
extras.testEnabled = false
extras.parentalGateEnabled = true
extras.orientation = .portrait
let interstitialReq = GoogleMobileAds.Request()
interstitialReq.register(extras)
SAAdMobExtras *extras = [[SAAdMobExtras alloc] init];
extras.testEnabled = false;
extras.parentalGateEnabled = true;
extras.orientation = OrientationPortrait;
GADRequest *interstitialReq = [GADRequest request];
[interstitialReq registerAdNetworkExtras:extras];
Customize a rewarded video ad
Supported properties: testEnabled, parentalGateEnabled, bumperPageEnabled, orientation, closeButtonEnabled, closeAtEndEnabled, smallCLickEnabled, playbackMode
let extras = SAAdMobExtras()
extras.testEnabled = false
extras.closeAtEndEnabled = true
extras.closeButtonEnabled = false
extras.parentalGateEnabled = false
extras.smallCLickEnabled = true
extras.orientation = .landscape
let videoReq = GoogleMobileAds.Request()
videoReq.register(extras)
SAAdMobExtras *extras = [[SAAdMobExtras alloc] init];
extras.testEnabled = false;
extras.closeAtEndEnabled = true;
extras.closeButtonEnabled = false;
extras.parentalGateEnabled = false;
extras.smallCLickEnabled = true;
extras.orientation = OrientationLandscape;
GADRequest *videoReq = [GADRequest request];
[videoReq registerAdNetworkExtras:extras];