iOS

All iOS 14 information is available on this page.
Starting with Chartboost iOS SDK version 8.3.1, iOS 10 is the minimum supported iOS version. Only earlier versions of the Chartboost iOS SDK retain support for older iOS versions.


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.
      • 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.1.0 to 8.2.0 consult this page to review the changes to our GDPR methods.
      • 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.
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.

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 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 and additional identifiers to the SKAdNetworkItems array in your Info.plist.
 
See our required SKAdNetwork IDs list and to know more about editing your Info.plist please check Apple’s SKAdNetwork Configuring the Participating Apps and Editing your property lists pages.
 
<key>SKAdNetworkItems</key>
<array>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>2U9PT9HC89.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>44jx6755aq.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4FZDC2EVR5.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4PFYVQ9L8R.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>737z793b9f.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>7UG5ZH24HU.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>8s468mfl3y.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>9RD848Q2BZ.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>9T245VHMPL.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>av6w8kgt66.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>c6k4g5qg8m.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>CJ5566H2GA.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>F38H382JLK.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>GLQZH8VGBY.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>hs6bdukanm.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>mlmmfzh3r3.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>prcb7njmu6.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>T38B2KH725.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>TL55SBB4FM.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>W9Q455WK68.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>wg4vff78zm.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>YCLNXRL5PM.skadnetwork</string>
  <dict/>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ydx93a7ass.skadnetwork</string>
  <dict/>
</array>
 
Include an additional dictionary to the array for each additional network in the list of available SKAdNetwork IDs (Note: Chartboost will periodically update the list).

Configure App Transport Security in your Info.plist

Apple introduced ATS in iOS 9 to prevent apps from making cleartext HTTP requests. Although Chartboost itself uses only HTTPS, some ads may use HTTP to load some resources.
 
This is why we recommend that you set in your app’s Info.plist the keys NSAllowsArbitraryLoads, NSAllowsArbitraryLoads, NSAllowsArbitraryLoadsInWebContent to true:
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsForMedia</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

Import the Chartboost in your Swift project’s bridging header

If you want to use Chartboost in your Swift code, create a bridging header and add the line #import <Chartboost/Chartboost.h>.

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 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 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.

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.

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 cache];
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.

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


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

▲ Back to top