Skip to main content

CloudX iOS SDK

Requires iOS 14.0+ and Xcode 12.0+.

Installation

CocoaPods

Podfile
platform :ios, '14.0'

target 'YourApp' do
  use_frameworks!
  
  # Core SDK
  pod 'CloudXCore'
  
  # Adapters (add as needed)
  pod 'CloudXMetaAdapter'     # Meta Audience Network
  pod 'CloudXVungleAdapter'   # Vungle (Liftoff)
  
  # CloudX Renderer (for test ads)
  pod 'CloudXRenderer'
end
pod install --repo-update
CloudXRenderer handles ad markup rendering with MRAID 3.0 and VAST 4.0 support. It is only required for rendering test ads at the moment.

Initialization

#import <CloudXCore/CloudXCore.h>

[[CloudXCore shared] initializeSDKWithAppKey:@"your-app-key-here" 
                                    testMode:NO
                                  completion:^(BOOL success, CLXError * _Nullable error) {
    if (success) {
        NSLog(@"CloudX SDK initialized successfully");
    } else {
        NSLog(@"Failed to initialize CloudX SDK: %@", error.localizedDescription);
    }
}];

Ad Integration

@interface YourViewController () <CLXBannerDelegate>
@property (nonatomic, strong) CLXBannerAdView *bannerAd;
@end

@implementation YourViewController

- (void)createBannerAd {
    self.bannerAd = [[CloudXCore shared] createBannerWithPlacement:@"your-banner-placement"
                                                    viewController:self
                                                          delegate:self
                                                              tmax:nil];
    
    if (self.bannerAd) {
        self.bannerAd.translatesAutoresizingMaskIntoConstraints = NO;
        [self.view addSubview:self.bannerAd];
        
        [NSLayoutConstraint activateConstraints:@[
            [self.bannerAd.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor],
            [self.bannerAd.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
            [self.bannerAd.widthAnchor constraintEqualToConstant:320],
            [self.bannerAd.heightAnchor constraintEqualToConstant:50]
        ]];
        
        [self.bannerAd load];
    }
}

#pragma mark - CLXBannerDelegate

- (void)didLoadAd:(CLXAd *)ad {
    NSLog(@"Banner ad loaded successfully");
}

- (void)didFailToLoadAdWithError:(CLXError *)error {
    NSLog(@"Banner ad failed to load: %@", error.localizedDescription);
}

- (void)didDisplayAd:(CLXAd *)ad {
    NSLog(@"Banner ad displayed");
}

- (void)didClickAd:(CLXAd *)ad {
    NSLog(@"Banner ad clicked");
}

- (void)didHideWithAd:(CLXAd *)ad {
    NSLog(@"Banner ad hidden");
}

@end

MREC Ads

@interface YourViewController () <CLXBannerDelegate>
@property (nonatomic, strong) CLXBannerAdView *mrecAd;
@end

@implementation YourViewController

- (void)createMRECAd {
    self.mrecAd = [[CloudXCore shared] createMRECWithPlacement:@"your-mrec-placement"
                                                viewController:self
                                                      delegate:self];
    
    if (self.mrecAd) {
        self.mrecAd.translatesAutoresizingMaskIntoConstraints = NO;
        [self.view addSubview:self.mrecAd];
        
        [NSLayoutConstraint activateConstraints:@[
            [self.mrecAd.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
            [self.mrecAd.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor constant:-20],
            [self.mrecAd.widthAnchor constraintEqualToConstant:300],
            [self.mrecAd.heightAnchor constraintEqualToConstant:250]
        ]];
        
        [self.mrecAd load];
    }
}

#pragma mark - CLXBannerDelegate

- (void)didLoadAd:(CLXAd *)ad {
    NSLog(@"MREC ad loaded successfully");
}

- (void)didFailToLoadAdWithError:(CLXError *)error {
    NSLog(@"MREC ad failed to load: %@", error.localizedDescription);
}

- (void)didDisplayAd:(CLXAd *)ad {
    NSLog(@"MREC ad displayed");
}

- (void)didClickAd:(CLXAd *)ad {
    NSLog(@"MREC ad clicked");
}

- (void)didHideWithAd:(CLXAd *)ad {
    NSLog(@"MREC ad hidden");
}

@end

Interstitial Ads

@interface YourViewController () <CLXInterstitialDelegate>
@property (nonatomic, strong) CLXInterstitial *interstitialAd;
@end

@implementation YourViewController

- (void)createInterstitialAd {
    self.interstitialAd = [[CloudXCore shared] createInterstitialWithPlacement:@"your-interstitial-placement"];
    self.interstitialAd.delegate = self;
    
    if (self.interstitialAd) {
        [self.interstitialAd load];
    }
}

- (void)showInterstitialAd {
    if (self.interstitialAd.isReady) {
        [self.interstitialAd showFromViewController:self];
    } else {
        NSLog(@"Interstitial ad not ready");
    }
}

#pragma mark - CLXInterstitialDelegate

- (void)didLoadAd:(CLXAd *)ad {
    NSLog(@"Interstitial ad loaded successfully");
}

- (void)didFailToLoadAdWithError:(CLXError *)error {
    NSLog(@"Interstitial ad failed to load: %@", error.localizedDescription);
}

- (void)didDisplayAd:(CLXAd *)ad {
    NSLog(@"Interstitial ad displayed");
}

- (void)failToShowWithAd:(CLXAd *)ad error:(CLXError *)error {
    NSLog(@"Interstitial ad failed to show: %@", error.localizedDescription);
}

- (void)didHideWithAd:(CLXAd *)ad {
    NSLog(@"Interstitial ad hidden");
    [self createInterstitialAd]; // Reload for next use
}

- (void)didClickWithAd:(CLXAd *)ad {
    NSLog(@"Interstitial ad clicked");
}

@end

Advanced Features

Debug Logging

// Enable verbose logging before SDK initialization
[CloudXCore setLoggingEnabled:YES];

Test Mode

Pass testMode: true during initialization to enable test ads during development:
[[CloudXCore shared] initializeSDKWithAppKey:@"your-app-key" testMode:YES completion:^(BOOL success, CLXError *error) {
    // Test ads enabled
}];

Privacy Compliance

The CloudX SDK supports GDPR and CCPA privacy compliance by reading standard IAB privacy strings from NSUserDefaults. These values are typically set automatically by your Consent Management Platform (CMP).

Supported Privacy Keys

KeyDescription
IABTCF_TCStringGDPR TC String
IABTCF_gdprAppliesWhether GDPR applies (1 = yes, 0 = no)
IABUSPrivacy_StringCCPA privacy string
IABGPP_HDR_GppStringGlobal Privacy Platform string
IABGPP_GppSIDGPP Section IDs

User Targeting

// Set hashed user ID
[[CloudXCore shared] setHashedUserID:@"hashed-user-id"];

// User-level targeting (cleared by privacy regulations)
[[CloudXCore shared] setUserKeyValue:@"age" value:@"25"];

// App-level targeting (NOT affected by privacy regulations)
[[CloudXCore shared] setAppKeyValue:@"app_version" value:@"1.2.0"];

// Clear all key-value pairs
[[CloudXCore shared] clearAllKeyValues];

Support

For support, contact [email protected]