App Open Ads
Integrate CloudX App Open ads in iOS apps
App Open ads are fullscreen placements intended for app foreground moments, such as when a user returns to your app after it has been backgrounded.
Supported Networks
App Open demand is served by the following bidding networks:
The Google Mobile Ads waterfall adapter also supports App Open placements for AdMob waterfall demand.
@interface YourViewController () <CLXAppOpenDelegate, CLXAdRevenueDelegate>
@property (nonatomic, strong) CLXAppOpen *appOpenAd;
@end
@implementation YourViewController
- (void)createAppOpenAd {
self.appOpenAd = [[CloudXCore shared] createAppOpenWithAdUnitId:@"your-app-open-ad-unit-id"];
self.appOpenAd.delegate = self;
self.appOpenAd.revenueDelegate = self;
[self.appOpenAd load];
}
- (void)showAppOpenAd {
if (self.appOpenAd.isReady) {
[self.appOpenAd showFromViewController:self];
} else {
NSLog(@"App Open ad not ready");
}
}
- (void)dealloc {
[self.appOpenAd destroy];
}
#pragma mark - CLXAppOpenDelegate
- (void)didLoadAd:(CLXAd *)ad {
NSLog(@"App Open ad loaded from %@", ad.networkName);
}
- (void)didFailToLoadAd:(NSString *)adUnitId error:(CLXError *)error {
NSLog(@"App Open ad failed to load: %@", error.localizedDescription);
}
- (void)didDisplayAd:(CLXAd *)ad {
NSLog(@"App Open ad displayed");
}
- (void)didFailToDisplayAd:(CLXAd *)ad error:(CLXError *)error {
NSLog(@"App Open ad failed to display: %@", error.localizedDescription);
[self.appOpenAd load];
}
- (void)didHideAd:(CLXAd *)ad {
NSLog(@"App Open ad hidden");
[self.appOpenAd load]; // Reload for next use
}
- (void)didClickAd:(CLXAd *)ad {
NSLog(@"App Open ad clicked");
}
#pragma mark - CLXAdRevenueDelegate
- (void)didPayRevenueForAd:(CLXAd *)ad {
NSLog(@"App Open revenue: %@ from %@", ad.revenue, ad.networkName);
}
@endclass YourViewController: UIViewController, CLXAppOpenDelegate, CLXAdRevenueDelegate {
private var appOpenAd: CLXAppOpen?
func createAppOpenAd() {
appOpenAd = CloudXCore.shared.createAppOpen(adUnitId: "your-app-open-ad-unit-id")
appOpenAd?.delegate = self
appOpenAd?.revenueDelegate = self
appOpenAd?.load()
}
func showAppOpenAd() {
if appOpenAd?.isReady == true {
appOpenAd?.show(from: self)
} else {
print("App Open ad not ready")
}
}
deinit {
appOpenAd?.destroy()
}
// MARK: - CLXAppOpenDelegate
func didLoad(_ ad: CLXAd) {
print("App Open ad loaded from \(ad.networkName ?? "unknown")")
}
func didFailToLoadAd(_ adUnitId: String, error: CLXError) {
print("App Open ad failed to load: \(error.localizedDescription)")
}
func didDisplay(_ ad: CLXAd) {
print("App Open ad displayed")
}
func didFailToDisplay(_ ad: CLXAd, error: CLXError) {
print("App Open ad failed to display: \(error.localizedDescription)")
appOpenAd?.load()
}
func didHide(_ ad: CLXAd) {
print("App Open ad hidden")
appOpenAd?.load() // Reload for next use
}
func didClick(_ ad: CLXAd) {
print("App Open ad clicked")
}
// MARK: - CLXAdRevenueDelegate
func didPayRevenue(for ad: CLXAd) {
print("App Open revenue: \(ad.revenue ?? 0) from \(ad.networkName ?? "unknown")")
}
}Use App Open ads sparingly and only at natural app-open or app-resume transitions. Avoid showing one while the user is already interacting with app content.
Ad readiness
isReady is true from the moment an ad loads until you show it or destroy the ad object. An ad network can stop being able to show an ad without telling the SDK. isReady stays true in that case, and the problem is found when you call showFromViewController: (Swift show(from:)). If the network does report that its ad has expired, the ad is no longer ready.
- If you show an ad the network can no longer show,
didFailToDisplayAd:error:(SwiftdidFailToDisplay(_:error:)) fires and the ad is no longer ready. Callloadto get a new ad. - In that case, if CloudX has enabled show recovery for your app and ad unit, the SDK loads a replacement and shows it instead. You receive the replacement’s display and revenue callbacks, and no
didFailToDisplayAd:error:. If an expired-ad replacement is already loading, the SDK uses it, anddidReloadExpiredAd:withNewAd:(SwiftdidReloadExpiredAd(_:with:)) fires before it is shown. If no replacement loads, or none is ready within the time limit CloudX sets,didFailToDisplayAd:error:fires. - If you call
loadwhile an ad is ready, no new request starts.didLoadAd:(SwiftdidLoad(_:)) fires at once with that ad. - A
loadcall while an ad is showing runs after the ad closes. Aloadcall while a show waits for a recovery replacement also runs after the show ends, and receives exactly onedidLoadAd:ordidFailToLoadAd:error:.
Expired ads
A loaded ad that is not shown before it expires is reloaded automatically on the same ad object. The current ad stays ready and can still be shown until the replacement is ready.
- To be told when a replacement is ready, set an
expirationDelegate. A replacement that loads on its own does not calldidLoadAd:(SwiftdidLoad(_:)) again. - If you show the ad while the replacement loads, the replacement is kept. If it is ready when the ad closes, or no
loadcomes before it is ready, it becomes ready on the ad object and theexpirationDelegateis called then. If you callloadafter the ad closes while the replacement is still loading, thatloadruns its own request and getsdidLoadAd:, and noexpirationDelegatecall follows for that replacement. - If you call
loadwhile the expired ad is still loaded, no new request starts.didLoadAd:fires at once with the expired ad. The replacement keeps loading, anddidReloadExpiredAd:withNewAd:(SwiftdidReloadExpiredAd(_:with:)) is called when it is ready. - If the replacement fails to load while the expired ad is still loaded,
didFailToLoadAd:error:(SwiftdidFailToLoadAd(_:error:)) fires and the ad is no longer ready. Reload and its retries are set per ad unit by CloudX, and retries are off by default, so one no-fill ends here. This is the normal outcome, not an integration error: callloadagain after a delay rather than in a tight loop.
// Add CLXAdExpirationDelegate to the protocols YourViewController adopts
self.appOpenAd.expirationDelegate = self;
- (void)didReloadExpiredAd:(CLXAd *)expiredAd withNewAd:(CLXAd *)newAd {
NSLog(@"Expired App Open ad replaced by an ad from %@", newAd.networkName);
}// Add CLXAdExpirationDelegate to the protocols YourViewController adopts
appOpenAd?.expirationDelegate = self
func didReloadExpiredAd(_ expiredAd: CLXAd, with newAd: CLXAd) {
print("Expired App Open ad replaced by an ad from \(newAd.networkName ?? "unknown")")
}