AdColony iOS SDK Integration Guide
Overview
The AdColony iOS SDK 5.0.0 shows full-screen interstitial, rewarded and banner ads in your app, either directly or through Google AdMob and AppLovin MAX mediation.
| Format | Description |
|---|---|
| Interstitial | Full-screen video or display ad shown at natural breaks in your app |
| Rewarded | Full-screen ad that grants the user an in-app reward after completion |
| Banner | Inline view in standard sizes: 320x50, 300x250, 728x90, 160x600 |
Format availability through mediation differs. See the AdMob and MAX sections.
Requirements
- iOS 13.0 or higher for direct SDK integration
- iOS 15.0 or higher when you use the AdMob or MAX adapter
- Xcode: [XCODE VERSION TO BE CONFIRMED]
- An AdColony app ID and one or more zone IDs, created in the AdColony dashboard: https://dashboard.example.com
- For AdMob mediation: Google Mobile Ads SDK 11.2.0 or later 11.x. Google Mobile Ads SDK 12 is not supported by this adapter release.
- For MAX mediation: AppLovin SDK 13.0.0 or later 13.x
What's new in 5.0.0
- Support for SKAdNetwork 4 attribution.
- Ads now handle ringer-mode changes during video playback.
- Skip-to-store and close-to-store routing for ads that open the App Store.
Reminder: previously deprecated APIs. These APIs were deprecated in earlier releases and remain deprecated in 5.0.0:
configureWithAppID:zoneIDs:options:completion:(deprecated since 4.8.0). Zones no longer need to be declared at startup, and thezoneIDsargument is ignored. UseconfigureWithAppID:options:completion:.gdprRequiredandgdprConsentString(deprecated since 4.2.0), in favor of the generic privacy APIs (see Privacy and consent).
Project setup
Add the SDK with Swift Package Manager, CocoaPods or manually, add the -ObjC linker flag, then add your SKAdNetwork IDs to Info.plist. Everything else is handled for you.
1. Add the SDK
Choose one method.
Swift Package Manager (recommended). In Xcode, choose File > Add Package Dependencies and enter the package URL: https://packages.example.com/adcolony-ios-sdk. Select the AdColony product and add it to your app target. Version: 5.0.0. Then add -ObjC to Other Linker Flags (see Required linker flag).
CocoaPods. Add this line to your Podfile, then run pod install:
pod 'AdColony', '5.0.0'
Manual. Download AdColony.xcframework: https://downloads.example.com/adcolony-ios-sdk/5.0.0/AdColony.xcframework.zip. Drag it into your project, add it to your app target under Frameworks, Libraries, and Embedded Content, and set it to Embed & Sign, so the SDK's privacy manifest is copied into your app. Add -ObjC to Other Linker Flags.
Required linker flag
AdColony.xcframework is a static framework. In your app target's Build Settings, add -ObjC to Other Linker Flags (OTHER_LDFLAGS). This is required for Swift Package Manager and manual integration, and when you use the AdMob or MAX adapter. Swift Package Manager does not add this flag for you. CocoaPods adds -ObjC through its generated build settings, as long as your target's Other Linker Flags keep $(inherited).
Without -ObjC, the linker strips SDK classes and categories that are loaded at runtime. configureWithAppID:options:completion: then throws AdColonyLibraryIntegrityException ("Please add flags: -ObjC"), or the app crashes later with an "unrecognized selector" error.
2. Add SKAdNetwork IDs
Add the AdColony SKAdNetwork IDs to the SKAdNetworkItems array in your Info.plist, so installs from your ads can be attributed. Copy the full list from https://docs.example.com/adcolony/ios/skadnetwork-ids. IDs are case-sensitive.
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>[ID FROM THE LIST].skadnetwork</string>
</dict>
</array>
3. Handled for you
No manual changes are needed for system frameworks or App Transport Security. The SDK links its system frameworks and libraries automatically and needs no ATS exceptions.
The SDK ships its own privacy manifest (PrivacyInfo.xcprivacy). With Swift Package Manager, or with a manual installation set to Embed & Sign, Xcode includes it in your app automatically. If the framework is set to Do Not Embed, the privacy manifest isn't copied into your app.
If you integrated SDK 4.x, you can remove the system frameworks you linked by hand. Keep -ObjC.
4. Create your app and zones
In the AdColony dashboard, create your app and one zone for each ad placement (interstitial, rewarded or banner). Note the app ID and each zone ID. You pass them to the SDK in the following steps.
Initialization
Call configureWithAppID:options:completion: once, as early as possible, before requesting any ad. We recommend calling it from application:didFinishLaunchingWithOptions:.
Swift
import AdColony
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
AdColony.configure(withAppID: "YOUR_APP_ID", options: nil) { zones in
// Configured. You can start requesting ads.
}
return true
}
Objective-C
#import <AdColony/AdColony.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AdColony configureWithAppID:@"YOUR_APP_ID"
options:nil
completion:^(NSArray<AdColonyZone *> *zones) {
// Configured. You can start requesting ads.
}];
return YES;
}
Wait for the completion handler before you request ads. The completion handler runs on the main thread. If the SDK can't configure, zones is nil.
To change options after initialization, for example when a user signs in or updates consent, build an AdColonyAppOptions with the values you want and pass it to setAppOptions:. Pass the full set of options each time, because the new object replaces the previous one. [AdColony getAppOptions] returns the options currently in use.
[AdColony getSDKVersion] returns the SDK version string, which is useful in logs and support requests.
Configuration rules
- Use one app ID per app session. To use a different app ID, the app must be relaunched.
- Call configure only once. A second configure call within 5 seconds is rejected, and its completion receives nil
zones. - Pass your initial options to configure. Call
setAppOptions:only after the configure completion has run. An update sent before configuration finishes waits up to 15 seconds and is discarded if configuration hasn't finished by then. - Ad requests made before configuration finishes wait up to 15 seconds and then fail.
- If you use the AdMob or MAX adapter, don't call configure yourself. The adapter configures the SDK.
App options
Options live on AdColonyAppOptions. Each one is covered where it's used: the user ID in Rewarded ads, privacy signals in Privacy and consent, and test mode in Testing and troubleshooting.
Privacy and consent
Pass each privacy signal as two values on AdColonyAppOptions: whether the law applies to the user, and the user's consent value. Set them before configure, or later with setAppOptions:.
| Framework | Applies flag | Consent value |
|---|---|---|
| GDPR (EU/UK) | setPrivacyFrameworkOfType:ADC_GDPR isRequired:YES | IAB TCF v2 string (recommended), or "1" = consented / "0" = declined |
| CCPA (California) | setPrivacyFrameworkOfType:ADC_CCPA isRequired:YES | IAB US Privacy string (recommended), or "1" = not opted out / "0" = opted out |
| COPPA (US children) | setPrivacyFrameworkOfType:ADC_COPPA isRequired:YES | None |
IAB strings from your CMP. If your consent management platform (CMP) stores IAB strings in NSUserDefaults, as the IAB TCF v2 and US Privacy specs describe, the SDK reads them automatically:
IABTCF_TCStringis used as the GDPR consent value, andIABTCF_gdprAppliessets whether GDPR applies.IABUSPrivacy_Stringis used as the CCPA consent value.
When these keys are present, they take precedence over the GDPR and CCPA values you set in code. The SDK reads them when you call configure and each time you call setAppOptions:. If your CMP updates consent after the SDK is configured, call setAppOptions: again (with your full options) so the SDK picks up the new values.
The "1"/"0" values aren't IAB-compliant and may reduce fill from demand partners that accept only IAB signals.
Swift
let options = AdColonyAppOptions()
// GDPR
options.setPrivacyFrameworkOfType(ADC_GDPR, isRequired: true)
options.setPrivacyConsentString("YOUR_TCF_STRING", forType: ADC_GDPR)
// CCPA
options.setPrivacyFrameworkOfType(ADC_CCPA, isRequired: true)
options.setPrivacyConsentString("1YNN", forType: ADC_CCPA)
// COPPA
options.setPrivacyFrameworkOfType(ADC_COPPA, isRequired: true)
AdColony.configure(withAppID: "YOUR_APP_ID", options: options) { zones in }
// Later, after configure has completed: AdColony.setAppOptions(options)
Objective-C
AdColonyAppOptions *options = [AdColonyAppOptions new];
// GDPR
[options setPrivacyFrameworkOfType:ADC_GDPR isRequired:YES];
[options setPrivacyConsentString:@"YOUR_TCF_STRING" forType:ADC_GDPR];
// CCPA
[options setPrivacyFrameworkOfType:ADC_CCPA isRequired:YES];
[options setPrivacyConsentString:@"1YNN" forType:ADC_CCPA];
// COPPA
[options setPrivacyFrameworkOfType:ADC_COPPA isRequired:YES];
[AdColony configureWithAppID:@"YOUR_APP_ID" options:options completion:^(NSArray<AdColonyZone *> *zones) {}];
// Later, after configure has completed: [AdColony setAppOptions:options];
To mark all of an app's inventory as child-directed, you can also configure the app as COPPA-applicable in the AdColony dashboard.
App Tracking Transparency (ATT) and IDFA
Ask for tracking permission before you configure the SDK, if your app tracks users. The SDK reads the current ATT status. It uses the IDFA only when the user has authorized tracking.
Add NSUserTrackingUsageDescription to your Info.plist with a short reason for the prompt, then request permission:
Swift
import AppTrackingTransparency
ATTrackingManager.requestTrackingAuthorization { _ in
AdColony.configure(withAppID: "YOUR_APP_ID", options: nil) { zones in }
}
Objective-C
#import <AppTrackingTransparency/AppTrackingTransparency.h>
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
[AdColony configureWithAppID:@"YOUR_APP_ID" options:nil completion:^(NSArray<AdColonyZone *> *zones) {}];
}];
The request only shows a prompt when the app is active, so call it after your first screen appears if you see no prompt at launch. Ads still serve when the user declines, with less targeting.
Interstitial ads
Request an interstitial ahead of time, keep the AdColonyInterstitial you receive, and show it at a natural break in your app.
Swift
import AdColony
class ViewController: UIViewController, AdColonyInterstitialDelegate {
private var interstitial: AdColonyInterstitial?
func requestInterstitial() {
AdColony.requestInterstitial(inZone: "YOUR_ZONE_ID", options: nil, andDelegate: self)
}
func showInterstitial() {
if let ad = interstitial, !ad.expired {
ad.show(withPresenting: self)
}
}
// Required
func adColonyInterstitialDidLoad(_ interstitial: AdColonyInterstitial) {
self.interstitial = interstitial
}
func adColonyInterstitialDidFail(toLoad error: AdColonyAdRequestError) {
print("Interstitial failed: \(error.localizedDescription)")
}
// Optional
func adColonyInterstitialDidClose(_ interstitial: AdColonyInterstitial) {
self.interstitial = nil
requestInterstitial()
}
func adColonyInterstitialExpired(_ interstitial: AdColonyInterstitial) {
self.interstitial = nil
requestInterstitial()
}
}
Objective-C
#import <AdColony/AdColony.h>
@interface ViewController () <AdColonyInterstitialDelegate>
@property (nonatomic, strong) AdColonyInterstitial *interstitial;
@end
@implementation ViewController
- (void)requestInterstitial {
[AdColony requestInterstitialInZone:@"YOUR_ZONE_ID" options:nil andDelegate:self];
}
- (void)showInterstitial {
if (self.interstitial && !self.interstitial.expired) {
[self.interstitial showWithPresentingViewController:self];
}
}
// Required
- (void)adColonyInterstitialDidLoad:(AdColonyInterstitial *)interstitial {
self.interstitial = interstitial;
}
- (void)adColonyInterstitialDidFailToLoad:(AdColonyAdRequestError *)error {
NSLog(@"Interstitial failed: %@", error.localizedDescription);
}
// Optional
- (void)adColonyInterstitialDidClose:(AdColonyInterstitial *)interstitial {
self.interstitial = nil;
[self requestInterstitial];
}
- (void)adColonyInterstitialExpired:(AdColonyInterstitial *)interstitial {
self.interstitial = nil;
[self requestInterstitial];
}
@end
Delegate callbacks
Only adColonyInterstitialDidLoad: and adColonyInterstitialDidFailToLoad: are required. Override the others as needed. All callbacks run on the main thread.
| Callback | When it's called |
|---|---|
adColonyInterstitialDidLoad: | An ad loaded and is ready to show |
adColonyInterstitialDidFailToLoad: | No ad is available for the zone. The AdColonyAdRequestError has the reason |
adColonyInterstitialWillOpen: | The ad is about to open full screen |
adColonyInterstitialDidClose: | The ad closed and your app is visible again |
adColonyInterstitialExpired: | The loaded ad expired before it was shown. Request a new one |
adColonyInterstitialDidReceiveClick: | The user tapped the ad |
adColonyInterstitialWillLeaveApplication: | A tap is taking the user out of your app, for example to the App Store |
Good practices
- Request the next ad in
adColonyInterstitialDidClose:, so one is ready for the next break. - Each
AdColonyInterstitialcan be shown once. Checkexpiredbefore showing. showWithPresentingViewController:returns NO if the SDK wasn't ready to play the ad: for example, the ad expired or was already shown, another AdColony ad is already on screen, the current network doesn't meet the zone's settings, or the zone's play-frequency limit hasn't elapsed.- The SDK keeps only a weak reference to your delegate. Keep the delegate object alive until the ad closes.
- Don't request ads in a tight loop. The SDK accepts up to 3 requests per second for each zone and rejects requests above that rate.
- Use
cancelonly to dismiss an ad that is playing. Cancelling early lowers your revenue.
Rewarded ads
Rewarded ads use the same request and show calls as interstitials, plus a reward handler on the zone. Use a zone set up as a rewarded (V4VC) zone in the dashboard. A regular interstitial zone never sends a reward.
1. Register a reward handler
Set the handler on each rewarded zone in the configure completion. The SDK calls it on the main thread when a reward is granted.
Swift
let rewardedZoneIDs = ["YOUR_REWARDED_ZONE_ID"]
AdColony.configure(withAppID: "YOUR_APP_ID", options: nil) { zones in
for zone in zones ?? [] where rewardedZoneIDs.contains(zone.identifier) {
zone.setReward { success, name, amount in
if success {
// Grant `amount` of `name` to the user
}
}
}
}
Objective-C
NSArray<NSString *> *rewardedZoneIDs = @[@"YOUR_REWARDED_ZONE_ID"];
[AdColony configureWithAppID:@"YOUR_APP_ID" options:nil completion:^(NSArray<AdColonyZone *> *zones) {
for (AdColonyZone *zone in zones) {
if ([rewardedZoneIDs containsObject:zone.identifier]) {
[zone setReward:^(BOOL success, NSString *name, int amount) {
if (success) {
// Grant `amount` of `name` to the user
}
}];
}
}
}];
The reward is granted only when the user completes the ad. The reward callback can arrive before or after adColonyInterstitialDidClose:, so don't rely on the order of the two callbacks. Always check success: the handler can be called with success set to NO.
Each zone has a single reward handler. Setting a new handler replaces the previous one. The AdMob and MAX adapters set their own handler on the zone when they show an ad, so don't use the same rewarded zone for direct integration and mediation.
2. Request and show the ad
Request and show the ad exactly as in Interstitial ads, passing your rewarded zone ID. To show a confirmation dialog before the ad and a results dialog after it, pass AdColonyAdOptions:
Swift
let options = AdColonyAdOptions()
options.showPrePopup = true
options.showPostPopup = true
AdColony.requestInterstitial(inZone: "YOUR_REWARDED_ZONE_ID", options: options, andDelegate: self)
Objective-C
AdColonyAdOptions *options = [AdColonyAdOptions new];
options.showPrePopup = YES;
options.showPostPopup = YES;
[AdColony requestInterstitialInZone:@"YOUR_REWARDED_ZONE_ID" options:options andDelegate:self];
Before showing, you can read the zone with [AdColony zoneForID:]: rewarded, rewardName, rewardAmount and viewsUntilReward.
3. Set a user ID
Set a user ID if your server needs to know who earned the reward. It must be 128 characters or less. Set it before configure, or change it later, for example when a user signs in:
Swift
let options = AdColonyAppOptions()
options.userID = "user-1234"
AdColony.configure(withAppID: "YOUR_APP_ID", options: options) { zones in }
// Later, when the user changes (after configure has completed):
options.userID = "user-5678"
AdColony.setAppOptions(options)
Objective-C
AdColonyAppOptions *options = [AdColonyAppOptions new];
options.userID = @"user-1234";
[AdColony configureWithAppID:@"YOUR_APP_ID" options:options completion:^(NSArray<AdColonyZone *> *zones) {}];
// Later, when the user changes (after configure has completed):
options.userID = @"user-5678";
[AdColony setAppOptions:options];
Through mediation, set the user ID as described in the AdMob and MAX sections. The MAX adapter doesn't support a per-user ID.
4. Server-side reward verification (recommended)
Client-side rewards can't be fully secured. For virtual currency or anything of value, have AdColony call your server and credit the user there.
In the zone's settings in the dashboard, turn off client-side rewards and enter your callback URL. The URL can use HTTPS but must not require authentication.
If you set a user ID, append &custom_id=[CUSTOM_ID] to the callback URL so it's sent to your server.
AdColony calls your URL with these query parameters:
| Parameter | Description |
|---|---|
id | Unique transaction ID. Record it to reject duplicates |
uid | AdColony's internal device/user ID |
zone | The zone ID |
amount | Reward amount |
currency | Reward name |
verifier | MD5 hash for verifying the request |
custom_id | The user ID you set, if you appended it |
open_udid, udid, odin1, mac_sha1 | Legacy parameters, always empty |
Verify the request: compute MD5(id + uid + amount + currency + SECRET_KEY + custom_id) and compare it with verifier. SECRET_KEY is your zone's secret key from the dashboard. Leave out custom_id if you didn't append it.
Respond with a plain-text body:
| Response | Meaning |
|---|---|
vc_success | The user was credited, or this transaction ID was already credited |
vc_decline or vc_noreward | The verifier didn't match or the user is invalid. AdColony won't retry |
| Anything else | Temporary error. AdColony retries later |
Decline a transaction only if the verifier doesn't match or the user is invalid.
Example in pseudocode:
params = request.query
expected = md5(params.id + params.uid + params.amount + params.currency + SECRET_KEY + (params.custom_id or ""))
if expected != params.verifier: return "vc_decline"
if already_credited(params.id): return "vc_success"
credit(user_for(params.custom_id), params.amount, params.currency)
record(params.id)
return "vc_success"
Banner ads
Request a banner with requestAdViewInZone:withSize:viewController:andDelegate:, add the AdColonyAdView you receive to your layout, and call destroy when you remove it.
| Size constant | Dimensions (pt) |
|---|---|
kAdColonyAdSizeBanner | 320 x 50 |
kAdColonyAdSizeMediumRectangle | 300 x 250 |
kAdColonyAdSizeLeaderboard | 728 x 90 (tablets) |
kAdColonyAdSizeSkyscraper | 160 x 600 (tablets) |
For a custom size, use AdColonyAdSizeMake(width, height) or AdColonyAdSizeFromCGSize(size).
Swift
import AdColony
class ViewController: UIViewController, AdColonyAdViewDelegate {
@IBOutlet weak var bannerContainer: UIView!
private var banner: AdColonyAdView?
func requestBanner() {
AdColony.requestAdView(inZone: "YOUR_BANNER_ZONE_ID",
with: kAdColonyAdSizeBanner,
viewController: self,
andDelegate: self)
}
func adColonyAdViewDidLoad(_ adView: AdColonyAdView) {
banner?.destroy()
adView.frame = CGRect(x: 0, y: 0,
width: kAdColonyAdSizeBanner.width,
height: kAdColonyAdSizeBanner.height)
bannerContainer.addSubview(adView)
banner = adView
}
func adColonyAdViewDidFail(toLoad error: AdColonyAdRequestError) {
// No fill: hide the container or try again later
}
deinit { banner?.destroy() }
}
Objective-C
#import <AdColony/AdColony.h>
@interface ViewController () <AdColonyAdViewDelegate>
@property (nonatomic, weak) IBOutlet UIView *bannerContainer;
@property (nonatomic, strong) AdColonyAdView *banner;
@end
@implementation ViewController
- (void)requestBanner {
[AdColony requestAdViewInZone:@"YOUR_BANNER_ZONE_ID"
withSize:kAdColonyAdSizeBanner
viewController:self
andDelegate:self];
}
- (void)adColonyAdViewDidLoad:(AdColonyAdView *)adView {
[self.banner destroy];
adView.frame = CGRectMake(0, 0, kAdColonyAdSizeBanner.width, kAdColonyAdSizeBanner.height);
[self.bannerContainer addSubview:adView];
self.banner = adView;
}
- (void)adColonyAdViewDidFailToLoad:(AdColonyAdRequestError *)error {
// No fill: hide the container or try again later
}
- (void)dealloc {
[self.banner destroy];
}
@end
If you don't have a view controller when you request the banner, use requestAdViewInZone:withSize:options:andDelegate: and adopt AdColonyAdViewAdvancedDelegate. Return your view controller from adColonyAdViewHostViewController:.
The SDK keeps only weak references to the delegate and to the view controller. Keep both alive while the banner is on screen.
Delegate callbacks
Only adColonyAdViewDidLoad: and adColonyAdViewDidFailToLoad: are required. All callbacks run on the main thread.
| Callback | When it's called |
|---|---|
adColonyAdViewDidLoad: | The banner loaded. Add it to your layout |
adColonyAdViewDidFailToLoad: | No ad is available for the zone |
adColonyAdViewDidShow: | The banner was added to a view in an active window |
adColonyAdViewDidReceiveClick: | The user tapped the banner |
adColonyAdViewWillOpen: / adColonyAdViewDidClose: | The banner opened or closed full-screen content |
adColonyAdViewWillLeaveApplication: | A tap is taking the user out of your app |
Each AdColonyAdView is a single ad. To show a new banner, request another one, swap it into the container, and call destroy on the old view. destroy also removes the view from its parent.
Google AdMob mediation
The AdColony AdMob adapter lets AdMob serve AdColony ads through a custom event in your mediation group. Your app keeps using the Google Mobile Ads APIs. You don't call the AdColony SDK directly.
| Item | Value |
|---|---|
| Adapter package | AdColonyAdmobAdapter 5.0.0.0 [VERSION TO BE CONFIRMED] |
| Minimum iOS version | 15.0 |
| Google Mobile Ads SDK | 11.2.0 or later 11.x. Version 12 isn't supported |
| Custom event class | AdColonyAdmobCustomEvent |
| Formats | Banner, interstitial and rewarded (waterfall custom event). Rewarded interstitial, native and app open ad units aren't supported |
The adapter version is the SDK version plus an adapter revision: 5.0.0.0 is the first adapter build for SDK 5.0.0. Use four components, because Google Mobile Ads reads the adapter version in that format.
1. Add the adapter
Swift Package Manager: add https://packages.example.com/adcolony-ios-admob-adapter and select the AdColonyAdmobCustomEvent product. CocoaPods: pod 'AdColonyAdmobAdapter', '5.0.0.0' [POD NAME TO BE CONFIRMED]. The adapter brings in the AdColony SDK, so you don't add it separately.
Also add the Google Mobile Ads SDK (11.x) and your AdMob app ID (GADApplicationIdentifier) to Info.plist, as Google describes. Add -ObjC to Other Linker Flags (see Required linker flag) and set your deployment target to iOS 15.0 or higher.
2. Set up the custom event in AdMob
- In the AdColony dashboard, note your app ID and create one zone per AdMob ad unit. Use a rewarded (V4VC) zone for rewarded ad units.
- In the AdMob console, go to Mediation and create or open a mediation group with platform iOS and the matching ad format.
- Under Waterfall ad sources, choose Add custom event. Give it a label (for example "AdColony") and a manual eCPM.
- For each ad unit in the group, set:
- Class name:
AdColonyAdmobCustomEvent - Parameter: a JSON object with your AdColony IDs.
{"app_id": "YOUR_ADCOLONY_APP_ID", "zone_ids": "YOUR_ZONE_ID"}For
zone_ids, enter exactly one zone ID per ad unit. If you enter several IDs, only the first one is used. - Class name:
- Save the mediation group. Changes can take up to an hour to reach devices.
The class name has no module prefix. Enter it exactly as shown, with no spaces.
If app_id or the zone ID is missing, the adapter fails the request and AdMob moves to the next source in the waterfall.
3. Load ads as usual
Start the Google Mobile Ads SDK and load ads with your AdMob ad unit IDs. AdMob initializes the AdColony SDK for you, so don't call configure yourself.
- Load ads only after the
startcompletion handler has run. The adapter needs Google Mobile Ads initialization to finish first. - When you start your app, load the ad units that use AdColony one after another, not all at once. The AdColony SDK can be configured only once every 5 seconds, so simultaneous first requests can fail with adapter error 104.
- Keep the loaded ad and present it at a natural break, not directly in the load completion.
Swift (Google Mobile Ads 11.x)
import GoogleMobileAds
class ViewController: UIViewController {
private var interstitial: GADInterstitialAd?
func startAds() {
GADMobileAds.sharedInstance().start { _ in
// Google Mobile Ads is ready. Load ads now.
self.loadInterstitial()
}
}
func loadInterstitial() {
GADInterstitialAd.load(withAdUnitID: "YOUR_ADMOB_AD_UNIT_ID", request: GADRequest()) { ad, error in
if let error = error {
print("Interstitial failed to load: \(error.localizedDescription)")
return
}
self.interstitial = ad
}
}
// Call at a natural break in your app.
func showInterstitial() {
guard let interstitial = interstitial else { return }
interstitial.present(fromRootViewController: self)
self.interstitial = nil
}
}
Objective-C
#import <GoogleMobileAds/GoogleMobileAds.h>
- (void)startAds {
[GADMobileAds.sharedInstance startWithCompletionHandler:^(GADInitializationStatus *status) {
// Google Mobile Ads is ready. Load ads now.
[self loadInterstitial];
}];
}
- (void)loadInterstitial {
[GADInterstitialAd loadWithAdUnitID:@"YOUR_ADMOB_AD_UNIT_ID"
request:[GADRequest request]
completionHandler:^(GADInterstitialAd *ad, NSError *error) {
if (error) {
NSLog(@"Interstitial failed to load: %@", error.localizedDescription);
return;
}
self.interstitial = ad; // @property (nonatomic, strong) GADInterstitialAd *interstitial;
}];
}
// Call at a natural break in your app.
- (void)showInterstitial {
if (self.interstitial) {
[self.interstitial presentFromRootViewController:self];
self.interstitial = nil;
}
}
Rewarded ads deliver the reward through the userDidEarnRewardHandler you pass to present(fromRootViewController:userDidEarnRewardHandler:), as with any other network.
App options and user ID
To pass AdColony app options through AdMob, set them on GADMediationAdapterAdColony.appOptions before you start the Google Mobile Ads SDK. For example, set a user ID for server-side rewards:
Swift
import AdColony
import AdColonyAdmobCustomEvent
GADMediationAdapterAdColony.appOptions.userID = "user-1234"
Objective-C
GADMediationAdapterAdColony.appOptions.userID = @"user-1234";
Privacy
- GDPR and CCPA: use Google's User Messaging Platform (UMP) or another IAB-certified CMP. The AdColony SDK reads the IAB TCF and US Privacy strings the CMP stores in NSUserDefaults.
- ATT: request tracking permission before you start the Google Mobile Ads SDK. See Privacy and consent.
- COPPA: the adapter forwards Google Mobile Ads' child-directed setting to AdColony as COPPA. Set
GADMobileAds.sharedInstance().requestConfiguration.tagForChildDirectedTreatment = truebefore you load ads.
Testing
Use AdMob test devices, and open the Ad Inspector to confirm the AdColony custom event is in the waterfall and to see why a request didn't fill.
AdMob test devices don't turn on AdColony test mode. To get AdColony test ads, enable test mode on the adapter's app options in debug builds, before you start the Google Mobile Ads SDK:
Swift
#if DEBUG
GADMediationAdapterAdColony.appOptions.testMode = true
#endif
Objective-C
#if DEBUG
GADMediationAdapterAdColony.appOptions.testMode = YES;
#endif
AppLovin MAX mediation
The AdColony MAX adapter lets MAX serve AdColony ads through a custom SDK network. Your app keeps using the MAX APIs. You don't call the AdColony SDK directly.
| Item | Value |
|---|---|
| Adapter package | AdColonyAppLovinMaxAdapter 5.0.0.0 [VERSION TO BE CONFIRMED] |
| Minimum iOS version | 15.0 |
| AppLovin SDK | 13.0.0 or later 13.x |
| iOS adapter class | AdColonyAppLovinCustomEvent |
| Formats | Banner (320x50), leaderboard (728x90), MREC (300x250), interstitial and rewarded (waterfall). Other formats, such as native and app open, aren't supported |
1. Add the adapter
Swift Package Manager: add https://packages.example.com/adcolony-ios-max-adapter and select the AdColonyAppLovinCustomEvent product. CocoaPods: pod 'AdColonyAppLovinMaxAdapter', '5.0.0.0' [POD NAME TO BE CONFIRMED]. The adapter brings in the AdColony SDK, so you don't add it separately.
Add -ObjC to Other Linker Flags (see Required linker flag) and set your deployment target to iOS 15.0 or higher.
2. Add AdColony as a custom network
In the MAX dashboard, go to MAX > Mediation > Manage > Networks, then choose Click here to add a Custom Network. Fill in the network:
- Network type: SDK
- Name: AdColony
- iOS adapter class name:
AdColonyAppLovinCustomEvent
Save the network.
3. Enable AdColony on each ad unit
- In the AdColony dashboard, create one zone per MAX ad unit. Use a rewarded (V4VC) zone for rewarded ad units.
- In MAX > Mediation > Manage > Ad Units, open the ad unit and find AdColony under Custom Networks. Enable it and set:
- App ID: your AdColony app ID
- Placement ID: the AdColony zone ID for this ad unit
- CPM price: your manual CPM for the waterfall
- Save the ad unit.
You can instead put the IDs in the Custom Parameters field as JSON. Values in App ID and Placement ID take priority when both are set. Note that the zone key is zone_id (singular) for MAX:
{"app_id": "YOUR_ADCOLONY_APP_ID", "zone_id": "YOUR_ZONE_ID"}
4. Load ads as usual
Initialize the AppLovin SDK and load ads with your MAX ad unit IDs. MAX initializes the AdColony SDK for you, so don't call configure yourself. Keep the loaded ad and show it at a natural break.
Swift
import AppLovinSDK
let config = ALSdkInitializationConfiguration(sdkKey: "YOUR_APPLOVIN_SDK_KEY") { builder in
builder.mediationProvider = ALMediationProviderMAX
}
ALSdk.shared().initialize(with: config) { _ in
self.interstitialAd = MAInterstitialAd(adUnitIdentifier: "YOUR_MAX_AD_UNIT_ID")
self.interstitialAd.delegate = self // MAAdDelegate
self.interstitialAd.load()
}
// Call at a natural break in your app.
func showInterstitial() {
if interstitialAd?.isReady == true {
interstitialAd.show()
}
}
// MAAdDelegate
func didLoad(_ ad: MAAd) {
// The ad is ready. Show it at the next natural break.
}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {}
func didFail(toDisplay ad: MAAd, withError error: MAError) {}
func didDisplay(_ ad: MAAd) {}
func didClick(_ ad: MAAd) {}
func didHide(_ ad: MAAd) { interstitialAd.load() }
Objective-C
#import <AppLovinSDK/AppLovinSDK.h>
ALSdkInitializationConfiguration *config =
[ALSdkInitializationConfiguration configurationWithSdkKey:@"YOUR_APPLOVIN_SDK_KEY"
builderBlock:^(ALSdkInitializationConfigurationBuilder *builder) {
builder.mediationProvider = ALMediationProviderMAX;
}];
[[ALSdk shared] initializeWithConfiguration:config completionHandler:^(ALSdkConfiguration *sdkConfig) {
self.interstitialAd = [[MAInterstitialAd alloc] initWithAdUnitIdentifier:@"YOUR_MAX_AD_UNIT_ID"];
self.interstitialAd.delegate = self; // MAAdDelegate
[self.interstitialAd loadAd];
}];
// Call at a natural break in your app.
- (void)showInterstitial {
if (self.interstitialAd.isReady) {
[self.interstitialAd showAd];
}
}
// MAAdDelegate
- (void)didLoadAd:(MAAd *)ad { /* The ad is ready. Show it at the next natural break. */ }
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error {}
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error {}
- (void)didDisplayAd:(MAAd *)ad {}
- (void)didClickAd:(MAAd *)ad {}
- (void)didHideAd:(MAAd *)ad { [self.interstitialAd loadAd]; }
Rewarded ads deliver the reward through MAX's MARewardedAdDelegate method didRewardUserForAd:withReward:, as with any other network.
App options and user ID
The MAX adapter builds the AdColony app options from your MAX settings on every ad load, so options you set directly with [AdColony setAppOptions:] are replaced. Use the AppLovin SDK's settings instead.
The adapter reads a user ID only from a user_id value in the ad unit's Custom Parameters, which is the same for all users. A per-user ID (for custom_id in server-side rewards) isn't supported through MAX.
Privacy
- GDPR and CCPA: set consent with the AppLovin SDK's privacy settings or an IAB-certified CMP. The AdColony SDK also reads the IAB TCF and US Privacy strings stored in NSUserDefaults.
- The adapter forwards AppLovin's GDPR consent value to AdColony, but not whether GDPR applies to the user. For users covered by GDPR, use an IAB TCF v2 CMP, which stores
IABTCF_gdprAppliesfor the SDK to read. - ATT: request tracking permission before you initialize the AppLovin SDK. See Privacy and consent.
- COPPA: with AppLovin SDK 13 and later, the adapter doesn't pass an age-restricted flag to AdColony, because AppLovin removed the API it read. If your app is child-directed, configure the app as COPPA-applicable in the AdColony dashboard.
Testing
Open the MAX Mediation Debugger ([ALSdk shared] showMediationDebugger) to confirm the AdColony custom network is loaded and to test-load each format. Register your device as a MAX test device. On a MAX test device, the adapter turns on AdColony test mode automatically.
Testing and troubleshooting
Turn on test mode while you develop, read the SDK's console logs, and check the issues below before contacting support.
Test mode
Enable test mode in debug builds only, so live users never see test ads.
Swift
let options = AdColonyAppOptions()
#if DEBUG
options.testMode = true
#endif
AdColony.configure(withAppID: "YOUR_APP_ID", options: options) { zones in }
Objective-C
AdColonyAppOptions *options = [AdColonyAppOptions new];
#if DEBUG
options.testMode = YES;
#endif
[AdColony configureWithAppID:@"YOUR_APP_ID" options:options completion:^(NSArray<AdColonyZone *> *zones) {}];
Through MAX, register a MAX test device and the adapter enables AdColony test mode for you. Through AdMob, set GADMediationAdapterAdColony.appOptions.testMode as shown in the AdMob Testing section. AdMob test devices alone don't enable it.
Logs
The SDK logs to the Xcode console by default. To turn logging off, set disableLogging = YES on AdColonyAppOptions before you configure.
Common issues
| Symptom | Likely cause and fix |
|---|---|
App crashes at launch with AdColonyLibraryIntegrityException, or with "unrecognized selector" in AdColony code | -ObjC is missing from Other Linker Flags. Add it to your app target. With CocoaPods, make sure Other Linker Flags keep $(inherited). See Required linker flag |
zones is nil in the configure completion | The app ID is empty or wrong, the device is offline, or configure was called again within 5 seconds. Copy the app ID from the dashboard and call configure once |
adColonyInterstitialDidFailToLoad: on every request | Wrong zone ID, a zone that's inactive or belongs to another app, too many requests per second, or no demand. Check error.code against AdColonyRequestError and try test mode |
| Rewarded ad plays but the reward handler never fires | The zone isn't a rewarded (V4VC) zone, setReward: wasn't set on that zone, or a mediation adapter replaced the handler on a zone you also use directly. If you use server-side rewards, credit the user from your server |
showWithPresentingViewController: returns NO | The ad expired or was already shown, another AdColony ad is on screen, or the zone's network or frequency settings don't allow playback now. Request a new ad in adColonyInterstitialExpired: and adColonyInterstitialDidClose: |
| Banner is cropped or stretched | The frame doesn't match the requested size. Set the frame to the size constant you requested |
| Installs from your ads aren't attributed | The SKAdNetwork IDs are missing from Info.plist. See Project setup |
| AdMob: custom event always fails | Check the class name AdColonyAdmobCustomEvent and that the Parameter is valid JSON with your app ID and zone ID |
| AdMob: error 104 (configured twice within five seconds) | Several AdColony ad units loaded at the same moment, or before Google Mobile Ads finished starting. Load after the start completion, one ad unit at a time |
| AdMob: package resolution fails | Your project uses Google Mobile Ads 12. This adapter release supports Google Mobile Ads 11.x |
| MAX: AdColony shows as not loaded in Mediation Debugger | Check the adapter class AdColonyAppLovinCustomEvent and that the adapter package is linked to your app target |
| MAX: requests fail with an empty zone ID | Set Placement ID on the ad unit, or use zone_id (not zone_ids) in Custom Parameters |
Migrating from SDK 4.x
- Update the SDK to 5.0.0.
- Replace
configureWithAppID:zoneIDs:options:completion:withconfigureWithAppID:options:completion:. - Replace
gdprRequiredandgdprConsentStringwithsetPrivacyFrameworkOfType:isRequired:andsetPrivacyConsentString:forType:. - Move any block-based ad callbacks to the delegate methods. Block callbacks were removed in 4.7.0.
- Make sure your deployment target is iOS 13.0 or higher, or iOS 15.0 or higher if you use the AdMob or MAX adapter.
- Make sure
-ObjCis in Other Linker Flags, including when you switch to Swift Package Manager. - If you used the AdColony adapters that Google or AppLovin used to publish, switch to the adapters in this guide and update the class names in your AdMob or MAX dashboard.
Support
- API reference: https://docs.example.com/adcolony/ios/api-reference
- Release notes: https://docs.example.com/adcolony/ios/release-notes/5.0.0
- Contact: support@example.com
SDK 5.0.0 · Nov 3, 2026