Monetize

Last Updated on

July 15, 2022

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.
  • 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 they just 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.

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.

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. You just need to open your project’s Podfile and add this line:

pod 'ChartboostSDK'

Then run this from the command line:

pod install --repo-update

Make sure to check CocoaPods’ documentation if you are new to it. 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 earlier than 12.4, 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.

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

See our iOS 14 Preparation page to learn more.

Import the Chartboost SDK

Initialize Chartboost in your didFinishLaunchingWithOptions method.

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

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:

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.

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.

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.

Last Updated on July 12, 2022