iOS SDK 8.1.0 Integration Guide


Before you begin:

  • 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.
  • If you are integrating an older SDK version (up to 8.0.4) follow this integration page instead.
  • If you are upgrading from SDK version 8.0.4 to 8.1.0 consult this page to review the changes to our public API and integration specifications.
  • Apps must be compiled with iOS base SDK higher than v8.0.
  • As of June 1, 2016, Apple requires that all submitted apps support IPv6.
  • The Chartboost SDK runs only on devices with iOS version higher than 8.0, iPhone 3GS or later, iPod 3rd generation or later, and iPad 2nd generation or later.
  • The bitcode version in iOS 10 is not backwards-compatible with Xcode v7.3.1. Please upgrade to Xcode v8.0+ to avoid bitcode compatibility errors, or disable bitcode in your Xcode v7.3.1 project.
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 setPIDataUseConsent API from the Chartboost SDK and pass in the appropriate value for whether consent exists, does not exist, or is unknown. 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.

Drop Chartboost.framework into your Xcode project.

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.


Link the StoreKit, Foundation, CoreGraphics, WebKit, AVFoundation, and UIKit frameworks.


Add the import header #import <Chartboost/Chartboost.h> to your AppDelegate.m file.


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:^(BOOL success) {
        // Chartboost was initialized if success is YES
    }];
    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 setPIDataUseConsent API from the Chartboost SDK and pass in the appropriate value for whether consent exists, does not exist, or is unknown. 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.

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 following method to cache an interstitial ad:
[interstitial cache];
Once the interstitial ad is cached you can display it using the method below:
[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 delegate method.
Learn more about iOS Chartboost delegate methods here.
Prefetched videos (in total) only take up 30-50MB, even when you are using mediation.

To show a rewarded video ad:

Rewarded ads need to be cached before being displayed. Use the following method to cache a rewarded ad:
[rewarded.Cached];
Once the rewarded ad is cached you can display it using the method below:
[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 delegate method.
Learn more about iOS Chartboost delegate methods here.
Prefetched videos (in total) only take up 30-50MB, even when you are using mediation.

To show a banner ad:

To make the banner ad show, first create it (detailed here), and then call the delegate method.
By default, a banner will automatically update its content on its own. The refresh default rate is 30s.
If you decide to disable banner auto-refreshing you can do that by setting the automaticallyRefreshesContent property to NO.

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.

w00t! You just integrated the Chartboost SDK into your app!

Now you can start a campaign ▶


Check out more Chartboost SDK features

  • Caching: Speed up load times for ads by storing them locally on devices.
  • Chartboost Video: Add beautiful, high-quality video ads to give players the best in-game experience.
  • Named locations: Fine-tune your campaign targeting and ad frequency from the dashboard.
  • Delegate methods: Gain more control over how your game behaves around ads.
  • SDK configuration methods: Access Chartboost SDK functionality and settings.
  • Mediation: Show your ads along a waterfall of other top-quality networks.

GDPR

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions       
{
    //Set the consent status corresponding to the user's response using 
    // the [Chartboost setPIDataUseConsent:YES_BEHAVIORAL] method.
    [Chartboost setPIDataUseConsent:YesBehavioral];

    //Get the consent status via the (CBPIDataUseConsent)getPIDataUseConsent method.
    CBPIDataUseConsent currConsent = [Chartboost getPIDataUseConsent];

    // Initialize the Chartboost library
    [Chartboost startWithAppId:@"YOUR_CHARTBOOST_APP_ID”
                  appSignature:@ "YOUR_CHARTBOOST_APP_SIGNATURE”
                    completion:^(BOOL success) {
        // Chartboost was initialized if success is YES
    }];
    return YES;
}
You might also like…
  • Error codes: Common problems and their solutions when integrating the SDK for iOS.

▲ Back to top



Last Updated on June 24, 2020