SDK Initialization
Initialize CloudX SDK in your AppDelegate:
import CloudXCore
// Basic initialization
CloudXCore. shared . initializeSDK ( withAppKey : "YOUR_APP_KEY" ) { success, error in
if success {
print ( "CloudX SDK initialized successfully" )
} else {
print ( "Initialization failed: \( error ? . localizedDescription ?? "Unknown error" ) " )
}
}
// With hashed user ID
CloudXCore. shared . initializeSDK (
withAppKey : "YOUR_APP_KEY" ,
hashedUserID : "hashed_user_id_123"
) { success, error in
if success {
print ( "CloudX SDK initialized with user ID" )
}
}
Initialize the SDK before creating any ads. Call this in application(_:didFinishLaunchingWithOptions:).
Privacy Settings
CloudX SDK provides privacy controls for GDPR, CCPA, and COPPA compliance.
GDPR User Consent
Set whether the user has provided consent under GDPR:
// User granted consent
CloudXCore. setIsUserConsent ( true )
// User denied consent
CloudXCore. setIsUserConsent ( false )
Call this method after obtaining user consent through your CMP (Consent Management Platform) or consent dialog.
COPPA Compliance
Mark users as age-restricted for COPPA compliance:
// Child-directed app or age-restricted user
CloudXCore. setIsAgeRestrictedUser ( true )
// General audience
CloudXCore. setIsAgeRestrictedUser ( false )
Set to true if your app is child-directed or the user is under 13 years old.
CCPA Privacy String
Set CCPA privacy string for California users:
// CCPA privacy string (IAB format)
CloudXCore. setCCPAPrivacyString ( "1YNN" )
// Example: User opted out of sale
CloudXCore. setCCPAPrivacyString ( "1YYN" )
Do Not Sell
Set the “Do Not Sell” flag for CCPA compliance:
// User opted out of data sale
CloudXCore. setIsDoNotSell ( true )
// User allows data sale
CloudXCore. setIsDoNotSell ( false )
Respect user privacy choices and update these settings when users change their preferences.
App Tracking Transparency
Request ATT permission on iOS 14+:
import AppTrackingTransparency
import AdSupport
func requestTrackingPermission () {
if #available ( iOS 14 , * ) {
ATTrackingManager. requestTrackingAuthorization { status in
switch status {
case . authorized :
print ( "Tracking authorized" )
// User granted permission - personalized ads enabled
case . denied :
print ( "Tracking denied" )
// User denied - show contextual ads only
case . restricted :
print ( "Tracking restricted" )
// Restricted by parental controls or device management
case . notDetermined :
print ( "Tracking not determined" )
@unknown default :
break
}
}
}
}
Request ATT permission before initializing the SDK for best ad performance. Add NSUserTrackingUsageDescription to your Info.plist.
Targeting and Key-Values
Hashed User ID
Set a hashed user identifier for better targeting:
// Set hashed user ID (SHA-256 recommended)
CloudXCore. shared . setHashedUserID ( "sha256_hashed_user_id" )
User Key-Value Targeting
Set custom user-level targeting parameters:
// Set individual user key-value pairs
CloudXCore. shared . setUserKeyValue ( "interests" , value : "gaming" )
CloudXCore. shared . setUserKeyValue ( "subscription" , value : "premium" )
CloudXCore. shared . setUserKeyValue ( "level" , value : "25" )
App Key-Value Targeting
Set app-level targeting parameters:
// Set app-level key-value pairs
CloudXCore. shared . setAppKeyValue ( "app_version" , value : "2.1.0" )
CloudXCore. shared . setAppKeyValue ( "build_type" , value : "release" )
Bidder Key-Value Targeting
Set bidder-specific targeting parameters:
// Set bidder-specific key-value pairs
CloudXCore. shared . setBidderKeyValue ( "meta" , key : "placement_type" , value : "interstitial" )
CloudXCore. shared . setBidderKeyValue ( "vungle" , key : "rewarded_type" , value : "video" )
Set Multiple Key-Values
Set multiple key-value pairs at once:
// Set dictionary of key-value pairs
let targeting: [ String : String ] = [
"interests" : "gaming,sports" ,
"age_range" : "25-34" ,
"gender" : "male" ,
"language" : "en"
]
CloudXCore. shared . setKeyValueDictionary (targeting)
Clear Key-Values
Clear all targeting key-value pairs:
// Clear all key-value pairs
CloudXCore. shared . clearAllKeyValues ()
Logging and Debugging
Enable Logging
Enable SDK logging for debugging:
// Enable logging
CloudXCore. setLoggingEnabled ( true )
// Disable logging (for production)
CloudXCore. setLoggingEnabled ( false )
Set Log Level
Control log verbosity:
// Set minimum log level
CloudXCore. setMinLogLevel (. debug ) // Show all logs
CloudXCore. setMinLogLevel (. info ) // Show info, warning, error
CloudXCore. setMinLogLevel (. warning ) // Show warning and error only
CloudXCore. setMinLogLevel (. error ) // Show errors only
CloudXCore. setMinLogLevel (. none ) // Disable all logs
Disable logging in production builds to avoid performance overhead and log pollution.
Check SDK initialization status and version:
// Check if SDK is initialized
if CloudXCore.shared.isInitialized {
print ( "SDK is ready" )
}
// Get SDK version
let version = CloudXCore. shared . sdkVersion
print ( "CloudX SDK version: \( version ) " )
Info.plist Configuration
Required keys in your Info.plist:
<!-- App Tracking Transparency (Required for iOS 14+) -->
< key > NSUserTrackingUsageDescription </ key >
< string > This identifier will be used to deliver personalized ads to you. </ string >
<!-- CloudX App Key -->
< key > GADApplicationIdentifier </ key >
< string > YOUR_APP_KEY </ string >
<!-- SKAdNetwork IDs for attribution -->
< key > SKAdNetworkItems </ key >
< array >
<!-- CloudX -->
< dict >
< key > SKAdNetworkIdentifier </ key >
< string > cloudx.skadnetwork </ string >
</ dict >
<!-- Meta/Facebook -->
< dict >
< key > SKAdNetworkIdentifier </ key >
< string > v9wttpbfk9.skadnetwork </ string >
</ dict >
< dict >
< key > SKAdNetworkIdentifier </ key >
< string > n38lu8286q.skadnetwork </ string >
</ dict >
<!-- Add more network IDs as needed -->
</ array >
Best Practices
Initialize the SDK in application(_:didFinishLaunchingWithOptions:) before creating any ads. Wait for the completion callback before loading ads.
Request App Tracking Transparency permission early in your app flow to enable personalized ads and better revenue.
Configure privacy settings (GDPR, CCPA, COPPA) before initializing the SDK based on user location and consent status.
Set relevant targeting parameters to improve ad relevance and performance. Don’t send personally identifiable information (PII).
Disable Logging in Production
Always disable debug logging in production builds to avoid performance impact and log clutter.
Always hash user identifiers (SHA-256) before passing them to the SDK. Never send plain text emails or IDs.
Complete Configuration Example
import UIKit
import CloudXCore
import AppTrackingTransparency
@main
class AppDelegate : UIResponder , UIApplicationDelegate {
func application (
_ application : UIApplication,
didFinishLaunchingWithOptions launchOptions : [UIApplication.LaunchOptionsKey: Any ] ?
) -> Bool {
// 1. Enable debug logging (development only)
# if DEBUG
CloudXCore. setLoggingEnabled ( true )
CloudXCore. setMinLogLevel (. debug )
# else
CloudXCore. setLoggingEnabled ( false )
# endif
// 2. Set privacy settings (before initialization)
CloudXCore. setIsUserConsent ( true ) // Set based on user consent
CloudXCore. setIsAgeRestrictedUser ( false ) // Set based on user age
CloudXCore. setIsDoNotSell ( false ) // Set based on CCPA preference
// 3. Set targeting parameters
CloudXCore. shared . setUserKeyValue ( "subscription" , value : "premium" )
CloudXCore. shared . setAppKeyValue ( "app_version" , value : "2.1.0" )
// 4. Initialize SDK
CloudXCore. shared . initializeSDK ( withAppKey : "YOUR_APP_KEY" ) { success, error in
if success {
print ( "CloudX SDK initialized successfully" )
// 5. Request ATT permission (iOS 14+)
self . requestTrackingPermission ()
} else {
print ( "SDK initialization failed: \( error ? . localizedDescription ?? "Unknown" ) " )
}
}
return true
}
private func requestTrackingPermission () {
if #available ( iOS 14 , * ) {
ATTrackingManager. requestTrackingAuthorization { status in
switch status {
case . authorized :
print ( "Tracking authorized - personalized ads enabled" )
case . denied :
print ( "Tracking denied - contextual ads only" )
default :
break
}
}
}
}
}
Next Steps