Before You Begin

The Chartboost SDK runs only on devices with iOS version 10.0 or higher, iPhone 5 or later, iPod 6th generation or later, and iPad 4th generation or later.

  • Have you signed up for a Chartboost account?
  • Did you add an app to your dashboard?
  • Did you download the latest SDK?
  • Did you download Chartboost Sample App.
  • Apps must be compiled with iOS base SDK higher than v10.0.
  • As of June 1, 2016, Apple requires that all submitted apps support IPv6.

📘

Note

  • For iOS 14+ information, see Upgrading the SDK documentation.
  • iOS 10 is the minimum supported version for Chartboost iOS SDK version 8.3.1 and above. Only earlier versions of the Chartboost iOS SDK retain support for older iOS versions.
  • Macs on M1: Publishers that use older SDK versions, or 8.5.0.2 without CocoaPods, won’t be able to run their apps on iOS simulator running on M1 Macs. To fix this, publishers need to go to their Xcode project Build Settings and add Any iOS Simulator SDK with value arm64 inside Excluded Architectures.
  • Xcode 13.1 is the minimum requirement for publishers when integrating Chartboost Ads SDK 9.0 and above.

startWithAppId must always be called during hard and soft bootups within the first few seconds of your app launching, regardless of any other actions or user interaction within your app.

Publishers should call the addDataUseConsent API from the Chartboost SDK and pass in the appropriate consent value for GDPR and CCPA. Publishers are required as part of Terms of Service to obtain the consent from their users before Chartboost will process any personal data and pass it to the Chartboost SDK via the above method. This method should be called before startWithAppId if possible.

Learn more about privacy methods here and Behavioral Targeting here.

Import the Chartboost framework ChartboostSDK.xcframework into your Xcode project.

Option 1: CocoaPods

The easiest way to download and link the Chartboost SDK to your project is to use CocoaPods.

  1. Open your project’s Podfile and add this line:

pod 'ChartboostSDK'

  1. Then, run this from the command line:

pod install --repo-update

Refer to CocoaPods’ documentation more for details. If you choose this option you should skip to step 4.

Option 2: Manual import

Download and drop ChartboostSDK.xcframework into your Xcode project. Mark it as Do Not Embed. If your project is pure Objective-C, you can add a Swift file or add the following settings to import the swift libraries.

  • Add Build Settings > Search Paths > Library search paths $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(SDKROOT)/usr/lib/swift
  • Add Build Settings > Linking > Runpath search paths /usr/lib/swift

If your project is targeting an iOS version 12.4 or earlier, set Build Settings > Always Embed Swift Standard Libraries to YES.

📘

Pro Tip

Checkmark the Copy items if needed option. This creates a local copy of the framework for your project, which keeps your project organized.

Add value -ObjC in Other Linker Flags under your project’s Build Settings for both Debug and Release.

Add a new dictionary with Chartboost’s SKAdNetworkIdentifier

This is a new required step for iOS 14 integrations.

Add a new dictionary with Chartboost’s SKAdNetworkIdentifier value f38h382jlk.skadnetwork as well as additional identifiers of other Chartboost Demand Partners to the SKAdNetworkItems array in your Info.plist.

The full list of Chartboost required SKAdNetwork IDs can be found here in XML and JSON formats.

SKAdNetworkItems 

SKAdNetworkIdentifier 
f38h382jlk.skadnetwork 

. 
. 
.

📘

Pro Tip:

We recommend enabling warning level logs in order to have our most up-to-date SKAdNetwork ID list.

See iOS 14 Preparation to learn more.

Import the Chartboost SDK

import ChartboostSDK
#import <ChartboostSDK/ChartboostSDK.h>

Initialize Chartboost in your didFinishLaunchingWithOptions method.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
// Initialize the Chartboost library    
    [Chartboost startWithAppId:@"YOUR_CHARTBOOST_APP_ID" 
        appSignature:@"YOUR_CHARTBOOST_APP_SIGNATURE" 
        completion:^(CHBStartError * _Nullable error) { 
        if (error) { 
            NSLog(@"Chartboost SDK initialization finished with error %@", error); 
        } else { 
            NSLog(@"Chartboost SDK initialization finished with success"); 
        } 
        }]; 
    return YES; 
}

startWithAppId must always be called during hard and soft bootups within the first few seconds of your app launching, regardless of any other actions or user interaction within your app.

Publishers should call the addDataUseConsent API from the Chartboost SDK and pass in the appropriate value for whether consent exists, does not exist, or is unknown. Publishers are required by the Terms of Service to obtain consent from their users before Chartboost can process any personal data and pass it to the Chartboost SDK via the above method. This method should be called before startWithAppId if possible.

Add your app ID and app signature.

Chartboost App ID is a unique App identifier in our systems, therefore it is required to use a different Chartboost App ID per each app

To show a static or video interstitial ad:

Interstitial ads need to be cached before being displayed. Use the method [interstitial cache]; to cache an interstitial ad.

Once the interstitial ad is cached you can display it using the method [interstitial showFromViewController:self];.

  • If an interstitial is tried to be shown but it is not cached yet, the operation will fail and the delegate method didShow:error: will be called with a CHBShowErrorCodeNoCachedAd error.
  • You can handle this error there or preemptively check the isCached property before showing the ad. This property indicates if an ad is ready to be shown.
  • Example:
if (interstitial.isCached) { 
    [interstitial showFromViewController:self]; 
}

To make the interstitial ad show, first create it (detailed here) then call the ad method.

Learn more about iOS Chartboost delegate methods here.

To show a rewarded video ad:

Rewarded ads need to be cached before being displayed. Use the method [rewarded cache]; to cache a rewarded ad.

Once the rewarded ad is cached you can display it using the method [rewarded showFromViewController:self];.

  • If a rewarded ad is tried to be shown but it is not cached yet, the operation will fail and the delegate method didShow:error: will be called with a CHBShowErrorCodeNoCachedAd error.
  • You can handle this error there or preemptively check the isCached property before showing the ad. This property indicates if an ad is ready to be shown.
  • Example:
if (rewarded.isCached) { 
    [rewarded showFromViewController:self]; 
}

To make the rewarded ad show, first create it (detailed here) then call the ad method.

Learn more about iOS Chartboost delegate methods here.

To show a banner ad:

Banner ads need to be cached before being displayed. Use the method [banner cache]; to cache a banner ad.

  • [banner showFromViewController:self]; is the Chartboost delegate method to show banner ads.
  • To make the banner ad show, first create it (detailed here), and then call the ad method.

Test your integration.

Check the SDK icon in the Chartboost dashboard

  • Go to your app’s App Settings > Basic Settings in your dashboard
  • When our servers successfully receive a bootup call from our SDK using your app ID, the SDK icon underneath your app’s icon will turn from gray to green.