iOS

 


 

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?
  • Do you have an active publishing campaign?
  • Apps must be compiled with iOS base SDK v6.0 or higher.
  • As of June 1, 2016, Apple requires that all submitted apps support IPv6.
  • The Chartboost SDK runs only on devices with iOS version 6.0 or higher, 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.

 


 

Unzip the SDK package and 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.

 


 

Link the StoreKit, Foundation, CoreGraphics, WebKit, 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" 
                      delegate:self];                     
    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.
You might receive a warning when passing an object as a delegate into the startWithAppID:appSignature:delegate: method. You can usually ignore this warning, but you can also resolve it by ensuring that the object you’re passing conforms to the ChartboostDelegate protocol.

 


 

Add your app ID and app signature.

 


 

To show a static or video interstitial ad:

  • [Chartboost showInterstitial:CBLocationHomeScreen]; shows the interstitial at location HomeScreen. See Chartboost.h for available location options.
  • For customized control over how ads behave in your game, the Chartboost SDK also offers more features such as caching, delegate methods, and named locations.
  • Learn more about Chartboost video ads.
Chartboost calls should always be made from a main – not background – thread, or these calls may time out!
We strongly recommend that you cache your interstitials before showing them. Learn more about caching ▶
Prefetched videos (in total) only take up 30-50MB, even when you are using mediation.

 

To show a rewarded video ad:

  • [Chartboost showRewardedVideo:CBLocationMainMenu]; shows the rewarded video pre-roll message and video ad at location MainMenu. See Chartboost.h for available location options.
  • For customized control over how ads behave in your game, the Chartboost SDK also offers more features such as caching, delegate methods, and named locations.
  • Learn more about Chartboost video ads.
Chartboost calls should always be made from a main – not background – thread, or these calls may time out!
We strongly recommend that you cache your interstitials before showing them. Learn more about caching ▶
Prefetched videos (in total) only take up 30-50MB, even when you are using mediation.

 

Test your integration.

  • Build and run your project from Xcode on a device or Simulator.
  • If you have an active publishing campaign and have integrated “show interstitial” or “show rewarded video” calls, you should see live ads.
  • If you don’t have any publishing campaigns and you’ve still integrated these calls, you can use Test Mode to see if test ads show up.
  • Why can’t I see ads in my game?

 


 

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.

 


 

Best practices

  • As noted in the iOS Human Interface Guidelines, it’s good practice to show interstitials only after the user has played your game for the first time.
  • You can use this Chartboost SDK delegate method to prevent interstitials until the second initialization call:
// For Chartboost SDKs v5.0+:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions       
{
    .
    .
    // Initialize the Chartboost library
    [Chartboost startWithAppId:@"YOUR_CHARTBOOST_APP_ID" 
                  appSignature:@"YOUR_CHARTBOOST_APP_SIGNATURE" 
                      delegate:self];
    // Prevent interstitials until after the user has played your game for the first time
    [Chartboost setShouldRequestInterstitialsInFirstSession:NO]
    .
    .
}


// For older Chartboost SDKs:
- (BOOL)shouldRequestInterstitialsInFirstSession {
    return NO;
}
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.

 


 

You might also like…
  • Error codes: Common problems and their solutions when integrating the SDK for iOS.

 

▲ Back to top