2.8.1-Beta iOS SDK Integration

Integrate SDK

You can use our demo app as a reference project.



1. Prepare your app

Set up the following keys in info.plist of your app:

In order to serve ads, the SDK requires you to allow arbitrary loads.

1. Go to your info.plist file, then press Add+ anywhere in the first column of the key list.

2. Add App Transport Security Settingskey and set its type to Dictionary in the second column.

3. Press Add+ at the end of the name App Transport Security Settingskey and choose Allow Arbitrary loads. Set its type to Boolean and its value to Yes.

You can also add the key to your info.plist directly, using this code:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>
4. In the info.plist file add GADApplicationIdentifier key (if you use APDGoogleAdMobAdapter). Add your AdMob app identifier as a String value.
<key>GADApplicationIdentifier</key>
<string>YOUR_ADMOB_APP_ID</string>

iOS 14 Update

Since Appodeal SDK v2.7.3 ad networks starting to support SKAdNetwork. To get more info about it please check this documentation page.

2. Choose your integration type

Fat and CocoaPods 2.8.1-Beta versions work in pure Obj-C, in pure Swift, in mixed Obj-C, Swift projects.

If your project is pure Objective-C project, you should add empty Swift file. For example Dummy.swift.

Minimum requirements:

  • iOS 10.0 or higher. You still can integrate the Appodeal SDK into a project with a lower value of minimum iOS version. On the devices that don’t support iOS 10.0+ our SDK will just be disabled.
  • The Appodeal SDK is compatible with both ARC and non-ARC projects.
  • Use XCode 12 or higher.

CocoaPods integration

1. Podfile configuration

CocoaPods 1.9.0 or higher is required. To get information about CocoaPods update please see this documentation.


2. Call pod install

Call $ pod install to install CocoaPods dependencies or $ pod update to update. If you do not have an installed pod, Install CocoaPods to simplify dependency management

sudo gem install cocoapods
If you have problems with versions of pods, please run the following code:
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
If the official repo doesn't respond, you can add aline to your podspec and update pods from the Appodeal mirror repository:
source 'https://github.com/appodeal/CocoaPods.git'
source 'https://cdn.cocoapods.org/'

3. Known issues

1. AdColony presentation issue

AdColony always checks, if the key window’s rootViewController matches the passed rootViewController. Otherwise, Adcolony fails to present the ad. If your app has multiple independent windows, you can get a message with this or similar text:

AdColony [*** ERROR ***] : AdColony has ads, but could not display them. AdColony was unable to find the currently visible UIViewController for your app. Please ensure that your key UIWindow has a rootViewController.

It means, that the rootViewController that was used in showAd, doesn't belong to the first window in the array. 

2. GoogleMobileAds issue

GoogleMobileAds will play music during ad downloading, if someone wants to change UserAgent on their custom UserAgent. The issue was detected in v. 7.33.1. This problem has not appeared in newer versions of the Google SDK (starting with v. 7.35.0), but then ads almost stop filling. 

Since GoogleMobileAds were updated to 7.42.0, you should add GADApplicationIdentifier in your's Info.plist. If you forget about it your application will fail with error:

The Google Mobile Ads SDK was initialized incorrectly.

3. AVAudioSession issue

If you use video or audio sessions in your app (usually for music players), you may encounter a problem with incorrect audio playback when loading an AdMob ad.
To solve this problem, add the following method to Your AppDelegate:

import GoogleMobileAds

final class AppDelegate ... {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = true
return true
}
}

More info you can find here: https://developers.google.com/admob/ios/global-settings#changing_audio_session

4. Initialise SDK

Import Appodeal into AppDelegate (AppDelegate.m) class and initialize the SDK:

import Appodeal
Add the initialization key under the didFinishLaunchingWithOptions function:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        Appodeal.initialize(withApiKey: "YOUR_API_KEY", types: adTypes, hasConsent: consent)
        return true
    }
The adTypes parameter is responsible for ad formats (ex. AppodealAdTypeRewardedVideo, AppodealAdTypeInterstitial).

consent is boolean, with 'false' meaning that the user declines to give the consent. Read our guide on collecting consent here.

Some of ad networks (eg Smaato, AmazonAd) can use IAB Consent framework 

Appodeal SDK does not modify any CMP keys in NSUserDefaults.

KeyValuesComments
IABConsent_CMPPresentBoolean (true)Set to true if a CMP implementing this specification is present in the application. Ideally set by the Publisher as soon as possible but can also be set by the CMP alternatively.
IABConsent_SubjectToGDPRString 1 - (subject to GDPR), 0 - (not subject to GDPR), Nil - undetermined (default before initialization)Aligns with IAB OpenRTB GDPR Advisory. Decided to be String, to have the uninitialized status.
IABConsent_ConsentStringConsent string as defined in "Cookie and vendor list format specification"Aligns with IAB OpenRTB GDPR Advisory
IABConsent_ParsedPurposeConsentsString (of "0" and "1") where the character in position N indicates the consent status to purpose ID N as defined in the Global Vendor List.String of consent given to enable simple checking. First character from the left being Purpose 1, ...
IABConsent_ParsedVendorConsentsString (of "0" and "1") where the character in position N indicates the consent status to vendor ID N as defined in the Global Vendor List.String of consent given to enable simple checking. First character from the left being Vendor 1, ...

Data Protection Regulation (GDPR, CCPA)

Publishers need to update their apps to collect the user consent prior to initializing our SDK (Read our guide on collecting consent here).

1. Starting from version 2.7.2 you can use the Stack Consent Manager SDK to process and pass the user's consent:

Read our implementation Stack Consent Manager guide here.

Publishers need to pass the Consent result object from Stack Consent Manager SDK to the +initialize method of our SDK.

let report = STKConsentManager.shared().consent!
Appodeal.initialize(withApiKey: YOUR_APPODEAL_APP_KEY, types: adTypes, consentReport: report)

2. If you don't want to use the Stack Content Manager SDK.

Publishers need to pass the boolean consent flag(with 'false' meaning that the user declined to give the consent) to the +initialize method of our SDK.

Appodeal.initialize(withApiKey: YOUR_APPODEAL_APP_KEY, types: adTypes, hasConsent: consent)

Publish your app

Before submitting your app to the App Store, you need to check the following settings.

1. Update Your IDFA Settings

When you submit your application to the App you need to update its "Advertising Identifier (IDFA)" settings in order to comply with Apple advertising policy.

1. Go to the Advertising Identifier section.

2. Set Yes on the right panel.

3. Tick Serve advertisements within the app.

4. Tick confirmation box under Limit Ad tracking setting in iOS.

2. Add usage descriptions to info.plist

If your app gets rejected by the App Store due to missing usage descriptions, add them to your info.plist file:

<key>NSLocationWhenInUseUsageDescription</key>
<string><App Name> needs your location for analytics and advertising purposes</string>
<key>NSCalendarsUsageDescription</key>
<string><App Name> needs your calendar to provide personalised advertising experience tailored to you</string>

It’s done!

You are ready to use Appodeal and implement ad types. If you have any questions, check out our FAQ or contact the support team.