SDK Integration | Appodeal Intelligent Ad Mediation

App key

Link your Admob account

Appodeal yields optimal results in cooperation with Admob. To continue, you need to link your Admob account.

If you don't have Admob account, please sign up on Admob.com.

To link your Admob account to Appodeal, use the Chrome extension:

INSTALL EXTENSION


The extension source code is available at https://github.com/appodeal/admob-configurator.

The extension will make two changes in your Admob account. First, it will allow Appodeal to access your Admob reports over API, and second, it will create new ad units on Admob and submit them to Appodeal.

VIDEO TUTORIAL

Appodeal iOS SDK 2.1.7 documentation

Download SDK

1.1 You can download Appodeal SDK 2.1.7 here

Known issues:

  • AdColony presentation issue: Sometimes you can see in logs something like this:
    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.
    This can happen when rootViewController that was used in showAd doesn't belong to the window that is the first object in the windows array. (AdColony checks if first window's rootViewController matches passed rootViewControler, and if it is not then AdColony fails to present ad and shows such error). This can happen when an application has multiple windows and each window is independent of the other windows in the app.

1.2 You can download a demo project for the release version here

iOS (Swift) integration

Preparing Your Apps

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

  • NSAllowsArbitraryLoads: YES
<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

CocoaPods integration

1. To download and integrate the Appodeal iOS SDK into your project using Cocoapods, add the following lines to your project's Podfile:

platform :ios, '8.0'   

target 'Name' do
pod 'Appodeal', '~> 2.1.7'
end

Also add use_frameworks! to your Podfile.

2. Make pod install to install CocoaPods dependencies or pod update to update. If you don`t have an installed pod - Install CocoaPods to simplify dependency management

sudo gem install cocoapods

If you have problems with versions of pods please run 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 repo

source 'https://github.com/appodeal/CocoaPods.git'
source 'https://github.com/CocoaPods/Specs.git'

3. You can add Pods with custom ad types:

Interstitial:

platform :ios, '8.0'   

target 'Name' do
pod 'Appodeal/Interstitial', '~>2.1.7'
end

Banners and MRECs:

platform :ios, '8.0'   

target 'Name' do
pod 'Appodeal/Banner', '~>2.1.7'
end

Rewarded video (nonskippable video):

platform :ios, '8.0'   

target 'Name' do
pod 'Appodeal/Video', '~>2.1.7'
end

Native ads:

platform :ios, '8.0'   

target 'Name' do
pod 'Appodeal/Native', '~>2.1.7'
end

Manual integration

1. Download the latest release FAT IOS SDK version and extract Appodeal iOS SDK.

2. Open your project in Xcode, then drag and drop Appodeal.framework and Resources folder onto your project or workspace (use the "Product Navigator view") and choose "Copy items into destination group's folder" and click "Finish".

Copy+
Add+fat

3. Add other frameworks and Flags that the SDK requires

Appodeal iOS SDK works on >= iOS 8.0 version and is compatible with both ARC and non-ARC projects. It depends (Project Settings -> Build Phases -> Link Binary With Libraries) on the following Apple frameworks:'

  • AdSupport
  • AudioToolbox
  • AVFoundation
  • CFNetwork
  • CoreGraphics
  • CoreImage
  • CoreLocation
  • CoreMedia
  • CoreMotion
  • CoreTelephony
  • EventKitUI
  • GLKit
  • ImageIO
  • JavaScriptCore
  • libc++
  • libsqlite3.dylib
  • libxml2.2.dylib
  • libz.dylib
  • MediaPlayer
  • MessageUI
  • MobileCoreServices
  • QuartzCore
  • Security
  • StoreKit
  • SystemConfiguration
  • Twitter
  • UIKit
  • WebKit

Linker Flags: Click Project -> Build Settings -> Search for other linker flags -> Add -ObjC

Ios xcode linker

SDK Initialization

Import Appodeal in AppDelegate and start sdk initialization with one of these methods:

let adTypes: AppodealAdType = [.interstitial, .rewardedVideo]
Appodeal.initializeWithApiKey("fee50c333ff3825fd6ad6d38cff78154de3025546d47a84f", types:  adTypes)

in didFinishLaunchingWithOptions method.

Types parameter is responsible for Ad types (ex. AppodealAdTypeRewardedVideo, AppodealAdTypeInterstitial). Ad types can be combined using "|" operator. For example AppodealAdTypeRewardedVideo | AppodealAdTypeInterstitial.

AppodealAdTypeSkippableVideo - deprecated Ad type. Appodeal Ad type AppodealAdTypeInterstitial now include AppodealAdTypeSkippableVideo

Display ad

To display ad you need to call the following code:

Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)

To display interstitial: use Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)

To display rewarded video: use Appodeal.showAd(AppodealShowStyle.rewardedVideo, rootViewController: self);

To display non-skippable video: use Appodeal.showAd(AppodealShowStyle.nonSkippableVideo, rootViewController: self)

To display banner at the bottom of the screen: use Appodeal.showAd(AppodealShowStyle.bannerBottom, rootViewController: self);

To display banner at the top of the screen: use Appodeal.showAd(AppodealShowStyle.bannerTop, rootViewController: self)

You can also display an ad with different show styles at the same time and the ad with the highest eCPM will be shown:

let showStyles: AppodealShowStyle = [.interstitial, .rewardedVideo]
Appodeal.showAd(showStyles, rootViewController: self)

IMPORTANT: SDK can't show ads in offline mode! You will get callback failToPresent if you call showAd without internet connection

Interstitial Integration

Interstitial ads provide full-screen experiences, commonly incorporating rich media to offer a higher level of interactivity than banner ads. Adding one to your app takes just a few lines of code.

Basic integration

import UIKit
Import Appodeal

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)
  }

}

Delegate callbacks (optional)

import UIKit
import Appodeal

class ViewController: UIViewController, AppodealInterstitialDelegate {
  override func viewDidLoad() {
    super.viewDidLoad()
    Appodeal.setInterstitialDelegate(self)
  }

    
    func interstitialDidLoadAdisPrecache(_ precache: Bool){
         NSLog("Interstitial was loaded")
    }
    func interstitialDidFailToLoadAd(){
         NSLog("Interstitial failed to load")
    }
    func interstitialWillPresent(){
         NSLog("Interstitial will present the ad")
    }
    func interstitialDidDismiss(){
         NSLog("Interstitial was closed")
    }
    func interstitialDidClick(){
         NSLog("Interstitial was clicked")
    }

}

Remember to set the delegate before making the request for an ad:

Appodeal.setInterstitialDelegate(self)

Display interstitial

Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)

Non skippable video integration

Basic integration

import UIKit
import Appodeal

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    Appodeal.showAd(AppodealShowStyle.nonSkippableVideo, rootViewController: self)
  }
}

Delegate callbacks (optional)

AppodealNonSkippableVideoDelegate protocol includes a variety of optional methods that you can use to be notified of events, e.g. when an video ad has successfully loaded, or when an video ad was completed. To handle these events you need to implement any of the optional methods of AppodealNonSkippableVideoDelegate protocol.

import UIKit
import Appodeal

class ViewController: UIViewController, AppodealNonSkippableVideoDelegate {

  override func viewDidLoad() {
    super.viewDidLoad()
    // set delegate
    Appodeal.setNonSkippableVideoDelegate(self)
  }

    func nonSkippableVideoDidLoadAd(){
         NSLog("video ad was loaded")
    }
    func nonSkippableVideoDidFailToLoadAd(){
         NSLog("video ad failed to load")
    }
    func nonSkippableVideoDidPresent(){
          NSLog("video ad was presented");
    }
    func nonSkippableVideoWillDismiss(){
          NSLog("video ad was closed");
    }
    func nonSkippableVideoDidFinish(){
          NSLog("video ad was fully watched");
    }
}

Remember to set the delegate before making the request for an ad:

Appodeal.setNonSkippableVideoDelegate(self)

Display Non skippable Video

Appodeal.showAd(AppodealShowStyle.nonSkippableVideo, rootViewController: self)

Rewarded video integration

Basic integration

import UIKit
import Appodeal

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    Appodeal.showAd(AppodealShowStyle.rewardedVideo, rootViewController: self)
  }
}

Delegate callbacks (optional)

AppodealRewardedVideoDelegate protocol includes a variety of optional methods that you can use to be notified of events, e.g. when an video ad has successfully loaded, or when an video ad was completed with reward (amount and name can be configured via Appodeal Dashboard). To handle this events you need to implement any of the optional methods of AppodealRewardedVideoDelegate protocol.

import UIKit
import Appodeal

class ViewController: UIViewController, AppodealRewardedVideoDelegate {

  override func viewDidLoad() {
    super.viewDidLoad()
    // set delegate
    Appodeal.setRewardedVideoDelegate(self)
  }

    func rewardedVideoDidLoadAd(){
         NSLog("video ad was loaded")
    }
    func rewardedVideoDidFailToLoadAd(){
         NSLog("video ad failed to load")
    }
    func rewardedVideoDidPresent(){
          NSLog("video ad was presented");
    }
    func rewardedVideoWillDismiss(){
          NSLog("video ad was closed");
    }
    func rewardedVideoDidFinish(_ rewardAmount: UInt, name rewardName: String!){
          NSLog("video ad was fully watched");
    }
}

Remember to set the delegate before making the request for an ad:

Appodeal.setRewardedVideoDelegate(self)

Display Rewarded Video

Appodeal.showAd(AppodealShowStyle.rewardedVideo, rootViewController: self)

S2S Rewards Callbacks

To secure your apps economy we offer S2S reward callbacks. To validate each reward you need to setup callback URL on your server that will receive reward information. We will pass user data to your callback URL that you will need to validate and adjust user balance accordingly.

1. Create reward callback URL on your server that will receive reward information.

2. Fill create URL and encryption key in the app settings in your dashboard.

3. Reward callback will be sent to your URL using GET request with two parameters:

{http:/example.com/reward}?data1={data1}&data2={data2}

4. Your URL should decrypt the data and validate it.

5. Check impression_id for uniqueness and store it in your system to prevent duplicate transactions.

We offer sample script in PHP, Ruby, Java and Python 3 to decrypt the data. If you need samples in other languages, please contact our support and we will provide it for you.

Sample in PHP: reward.php

Sample in Ruby: reward.rb

Sample in Java: reward.java

Sample in Python 3: reward.py

Get reward for placement

To get reward details (currency name and amount) for any placement you can use method `rewardForPlacement:(NSString *)placement`:

let rewardName = Appodeal.reward(forPlacement: "placement_name").currencyName
let rewardAmount = Appodeal.reward(forPlacement: "placement_name").amount

Banner Integration

Basic integration

Banner is a singleton now, if you are using bannerTop or bannerBottom on different controllers then SDK will use the same banner instance

import UIKit
import Appodeal

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    // show banner at the bottom of the screen
    Appodeal.showAd(AppodealShowStyle.bannerTop, rootViewController: self)
  }
}

Delegate callbacks (optional)

AppodealBannerDelegate protocol includes a variety of optional callbacks that you can use to be notified of events, e.g. when an ad banner has successfully loaded, or when an ad banner is about to appear. To handle callbacks, you need to implement AppodealBannerDelegate protocol.

import UIKit
import Appodeal
class ViewController: UIViewController, AppodealBannerDelegate {

  override func viewDidLoad() {
    super.viewDidLoad()
    //Remember to set the delegate before making the request for an ad
    Appodeal.setBannerDelegate(self)
  }

    func bannerDidLoadAdIsPrecache(_ precache: Bool){
        NSLog("banner was loaded")       
    }
    func bannerDidFailToLoadAd(){
         NSLog("banner failed to load");        
    }
    func bannerDidClick(){
        NSLog("banner was clicked")
    }
    func bannerDidShow(){
        NSLog("banner was shown")
    }
}

Remember to set the delegate before making the request for an ad:

Appodeal.setBannerDelegate(self)

Banner Position on the Screen

Appodeal supports the following banner positions:

AppodealShowStyleBannerBottom - pins ad banner at the bottom of the screen

AppodealShowStyleBannerTop - pins ad banner at the top of the screen

For example:

// pin ad banner at Bottom of the screen
Appodeal.showAd(AppodealShowStyle.bannerBottom, rootViewController: self)

// pin ad banner at Top of the screen
Appodeal.showAd(AppodealShowStyle.bannerTop, rootViewController: self)

You can also add Appodeal banner to your view hierarchy manually.

For example:

override func viewWillAppear(animated: Bool) {
  super.viewWillAppear(animated);

  self.view.addSubview(Appodeal.banner())
  Appodeal.banner().frame = CGRect.init(x: 0, y: 0, width: self.view.bounds.size.width, height: APPODEAL_BANNER_HEIGHT)
}

To remove banner from your view hierarchy:

Appodeal.hideBanner()

Advanced Banner View Integration

If basic integration is not appropriate due to the complex views hierarchy of your app, you can use AppodealBannerView UIView subclass to integrate banners.

To increase fillrate it's highly recommended to use one banner instance in application (to move it from one view controller to another)

import UIKit
import Appodeal

class YourViewController : : UIViewController, AppodealBannerViewDelegate {

  override func viewDidLoad () {
    super.viewDidLoad()
    // required: init ad banner
    var bannerView: AppodealBannerView!
    bannerView.init(size: kAppodealUnitSize_320x50, rootViewController: self);

    // optional: set delegate
    bannerView.setDelegate(self);

    // required: add banner to superview and call -loadAd to start banner loading
    self.view addSubview(bannerView);
    bannerView.loadAd();
  }

  // optional: implement any of AppodealBannerViewDelegate methods
    func bannerViewDidLoadAd(_ bannerView: APDBannerView!){
        NSLog("Banner view was loaded")
    }

    func bannerViewDidRefresh(_ bannerView: APDBannerView!){
        NSLog("banner view was refreshed")
    }
    func bannerView(_ bannerView: APDBannerView!, didFailToLoadAdWithError error: Error!){
        NSLog("banner view failed to load")
    }
    func bannerViewDidInteract(_ bannerView: APDBannerView!){
        NSLog("banner view was clicked")
    }
}

MREC Integration

Class "AppodealMRECView" is a subclass of "AppodealBannerView". 'AppodealMRECView' has size 300x250.

import UIKit
import Appodeal

class YourViewController : : UIViewController, AppodealBannerViewDelegate {

  override func viewDidLoad () {
    super.viewDidLoad()
    // required: init ad banner
    var mrec: AppodealMRECView!
    mrec.init(rootViewController: self);

    // optional: set delegate
    mrec.setDelegate(self);

    // required: add banner to superview and call -loadAd to start banner loading
    self.view addSubview(mrec);
    mrec.loadAd();
  }

  // optional: implement any of AppodealBannerViewDelegate methods
    func bannerViewDidLoadAd(_ bannerView: APDBannerView!){ 
         NSLog("banner view was loaded")   
    }
    func bannerViewDidRefresh(_ bannerView: APDBannerView!){  
         NSLog("banner view was refreshed")     
    }
    func bannerView(_ bannerView: APDBannerView!, didFailToLoadAdWithError error: Error!){
         NSLog("banner view failed to load")   
    }
    func bannerViewDidInteract(_ bannerView: APDBannerView!){  
         NSLog("banner view was clicked")   
    }
}

Skippable Video Integration

Skippable Video is now deprecated.

Interstitial now includes skippable video.

Native Ads Integration

A "Native Ad" gives you the opportunity to design and control the mobile app ad exactly as you would like it. Using Native Ads, you can create an ad experience that perfectly fits your application's design, flow, content and functionality.

Basic integration

Import the Appodeal in your view controller and add the following lines to the header file for each view in which you would like to show an ad.

import UIKit
import Appodeal

class YourViewController : UIViewController, APDNativeAdLoaderDelegate {
 var apdLoader : APDNativeAdLoader!
}

Initialize Appodeal native ad service object. You can do this in viewDidLoad method and call loadAd method.

    override func viewDidLoad() {
        super.viewDidLoad()
        apdLoader = APDNativeAdLoader.init()
        apdLoader.loadAd(with: .auto)
    }

Or method with capacity (Maximum capacity value: 10)

 override func viewDidLoad() {
        super.viewDidLoad()
        apdLoader = APDNativeAdLoader.init()
        apdLoader.loadAd(with: .auto, capacity: 5) //adLoader will load from 1 to 5 native ads, depending on how much ads ad network is providing
    }

NOTE: if you are using native ads with UITableView then you should attach it to contentView of current cell where the native ad is presented.

Using NativeAd delegates

Set your view controller as a delegate so it is able to receive callbacks from the native ad service.

Add the AppodealNativeAdLoaderDelegate protocol and set delegate

import UIKit
import Appodeal

class YourViewController : UIViewController, APDNativeAdLoaderDelegate {
 var apdLoader : APDNativeAdLoader! 

...

   override func viewDidLoad(){
     apdLoader = APDNativeAdLoader.init()
     apdLoader.delegate = self;
     apdLoader.loadAd(with: APDNativeAdType.auto)
   }

...

}

Implement the following functions:

func nativeAdLoader(_ loader: APDNativeAdLoader!, didLoad nativeAds: [APDNativeAd]!){
     NSLog("native ad was loaded")
}
func nativeAdLoader(_ loader: APDNativeAdLoader!, didFailToLoadWithError error: Error!){
     NSLog("native ad failed to load")        
}

Appodeal SDK also provides native ad presentation protocol to track the event when native ad was shown or clicked:

class YourViewController: UIViewController, APDNativeAdPresentationDelegate

Implement the following functions:

func nativeAdWillLogImpression(_ nativeAd: APDNativeAd!) {
   NSLog("native ad was shown")
}    
func nativeAdWillLogUserInteraction(_ nativeAd: APDNativeAd!) {
   NSLog("native ad was clicked")
}

Native complain button

You can choose the complain button position. Default complain button position - center

// use BEFORE attach
self.nativeAd.complainButtonPositon(.complainBottom)
self.nativeAd.attach(to: self.view, viewController: self)

Native Ad Queue

Native AdQueue is a new feature of using native ads in Appodeal SDK. You don't need to download native ads manually anymore. All you have to do is grab some ads from adQueue and adQueue will load new ads automatically.

Native Ad Queue initialization

import Appodeal
class ViewController: UIViewController {
    var adQueue : APDNativeAdQueue!

You can initialize nativeAdQueue with custom native count and type

class ViewController: UIViewController {
    var adQueue : APDNativeAdQueue!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.adQueue = APDNativeAdQueue.init()
        self.adQueue.setMaxAdSize(5)
        self.adQueue.loadAd(of: .video)
  }
}

Using NativeAdQueue delegates

class ViewController: UIViewController, APDNativeAdQueueDelegate { }

Implement the following functions:

func adQueueAdIsAvailable(_ adQueue: APDNativeAdQueue!, ofCount count: Int) {
     NSLog("native ads are available to be shown")
}

func adQueue(_ adQueue: APDNativeAdQueue!, failedWithError error: Error!) {
     NSLog("native ads loading failed")
}

Get all native ads from nativeAdQueue

import UIKit
import Appodeal

class ViewController: UIViewController, APDNativeAdQueueDelegate {
    var adQueue : APDNativeAdQueue!
    var nativeAds = [APDNativeAd]()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.adQueue = APDNativeAdQueue.init()
        self.adQueue.delegate = self
        self.adQueue.setMaxAdSize(5)
        self.adQueue.loadAd(of: .video)
    }

    func adQueueAdIsAvailable(_ adQueue: APDNativeAdQueue!, ofCount count: Int) {
        self.nativeAds = adQueue.getNativeAds(ofCount: 5)
    }


}

Using Media View

APDNativeAd provides video ads. You can show them with APDMediaView. That object created with native ad and rootViewController. APDMediaView uses image from native ad as placeholder. After this you can set boolean flags to mediaView: skippable and muted . If you set skippable to YES, then this video can be skipped after 5 seconds. You can add a custom mute button on media view and enabled/disabled sound playable video. When the video is completed, media view will show the image. If you use the APDMediaView as the main Image, you can set the type of media view.

func nativeAdLoader(_ loader: APDNativeAdLoader!, didLoad nativeAd: APDNativeAd!){

        let mediaView = APDMediaView.init(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
        self.view.addSubview(mediaView);
        mediaView.skippable = true
        mediaView.muted = false
        mediaView.setNativeAd(nativeAd, rootViewController: self)
}

You can set sound to mute while playing video. For example, you can unmute ad by usage:

  mediaView.muted = NO;

Appodeal Ad Choices View

Most ads networks require the use of data privacy view in native ad. APDNativeAd returns instance of UIView that is ad choices view. This view must not overlap any assets or be overlapped by any assets. The size of this icon should be 24x24 or more. If this element not required by the networks ad choices view, it will return nil.

class YourViewController : UIViewController {
  func nativeAdLoader(_ loader: APDNativeAdLoader!, didLoad nativeAd: APDNativeAd!){
        
        let adChoices = nativeAds.first?.adChoicesView
        adChoices!.frame = CGRect.init(x: 0, y: 0, width: 24, height: 24)
        self.view.addSubview(adChoices!)
  }
}

Native ads integration with UITableView

If you are using native ads with UITableView then you have to be sure that native ad was loaded before creating native ad cell. If ad was loaded - then after creating cell you will need to attach native ad to contentVIew of the cell. self.nativeAd.attach(to: cell.contentView, viewController: viewController:controller) . When you are creating native ad cell you can use xibs or you can create it manually in code. You can see xib example below:

Bcca5e5ed7

After native ad was loaded you will need to create native ad cell, and then assign its properties to properties of elements inside your custom cell.

(APDNativeAd.starRating, APDNativeAd.title, APDNativeAd.callToActionText и т.д.) свойствам текущей ячейки.

titleLabel.text =nativeAd.title;

descriptionLabel.text =nativeAd.descriptionText;

callToActionLabel.text =nativeAd.callToActionText; ...

If you use video native ads then you will need to use APDMediaView and assign mediaView inside cell to mediaView from native ad.

mediaView.setNativeAd(nativeAd, rootViewController: controller)

When native ad is going to be outside of the screen (when the cell is going to be reused) you will need to call nativeAd.detachFromView() to detach native ad from contentView of the cell.

Typical mistakes with placeing native ads in application

  • Absence of ad choices view

The majority of ad networks require from publisher to add special mark to native ad, so user could identify it as ad. Use ad choices view to help user with that.

WrongCorrect

  • Absence of required native ad elements

Don't forget that every native ad sould contain title, image, action button and ad choices view. Displaying that elements allows user to decide if he is interested in ad product.

Wrong (no action button)Correct

  • Native ad elements deformation

When advertiser is buying ad place in your app he expects that native ad will be displayed correctly, without any deformation. You can scale buttons and images but you shouldn't crop and deform them.

WrongCorrect

  • Overlaying elements of native ads on each other

Don't overlay elements of native ads to each other. It will affect user experience and ad will look bad.

WrongCorrect

Appodeal Native Ad Structure

Name of field Required? Description
String title; required field title of ads
String subtitle unrequired field subtitle of ads
String descriptionText unrequired field description of ads
String callToActionText required field call to action text
String contentRating unrequired field content rating
NSNumber starRating unrequired field means of star rating
APDImage mainImage unrequired field contains image size and url
APDImage iconImage required field contains icon size and url
UIView adChoicesView required field contains adChoicesView

All of the fields of native ad marked as mandatory must be displayed.

Every ad should have a sign that clearly indicates that it is an ad. For example "Ad" or "Sposored".

Provided images can be resized to fit your ad space but should not be significantly distorted or cropped.

Native object description

String title : Title of native ad. Mandatory. Minimum 25 symbols of title should always be displayed. You can add ellipsis at the end if the title is longer.

String subtitle : Subitle of native ad. Optional.

String callToActionText : Call to action text. Mandatory. Shoud be displayed without truncation on a visible button.

String descriptionText : Text description of native ad. Optional. If you choose to display the description you should display minimum 75 characters. You should limit number of lines displayed suitable for your app. You can add ellipsis at the end.

NSNumber starRating : Rating of the app in [0-5] range.

NSNumber contentRating : Content rating of the ad. Optional.

APDImage iconImage : Icon. Either icon or image is mandatory to display.

APDImage mainImage : Image. Either icon or image is mandatory to display.

UIView adChoicesView : If returned view is not null it is mandatory to display it in any corner of native ad. Only used for Facebook to display AdChoices icon.

Segments and Placements

Segments are divisions of your user base, which share commonalities such as age, sex, location, interests, income bracket, etc. There are several ways to segment users into groups including the use of demographics, in-app behavior or engagement analysis, interests and personal profile data, and location.

Once user segments have been created, they can then be analyzed and used to configure ads.

To create new segment, go here

1) Enter its name

2) Select match rule:

  • ALL - user will only match to segment if all of the rules will apply to them
  • ANY - user will match to segment if any of the rules will apply to them

3) Select platform

4) Select rules that apply to the user, you can select as many rules as you want or none at all:

  • App - matches users in one or multiple versions of your apps
  • SDK version - matches users that only use specified SDK version or range of versions
  • Device type - matches users that using tablet and/or phone
  • App version - matches users that only use specified app version or range of versions
  • Country - matches users only from specified countries
  • OS version - matches users that are using devices with specified OS version
  • Session count - matches users that had specified number of sessions in your app
  • Average session length - matches users with specified that spent specified average session length in your app
  • Device model - matches user on specified devices
  • Connection type - matches users using specified connection type
  • Gender, Age, Occupation, Relation - matches users with specified Gender, Age, Occupation, Relation
  • Last session time - matches users that last used your app at the specified time
  • Bought inapps - matches users that made in-app purchases (tracked using Appodeal.trackInAppPurchase method)
  • Inapp sum, Inapp sum all apps - matches users the spent specified amount in your the app or all apps (only counts in-apps tracked using Appodeal.trackInAppPurchase method)
  • Hour, Day - matches users using the app at the specified time
  • Integer, Float, String, Bool - matches users using custom parameters. You can set custom parameters in SDK using Appodeal.setCustomRule([AnyHashable : Any]!) method, i.e. Appodeal.setCustomRule(["levels_played" : 3]). To match users that played more than 3 level select Int and enter name "levels_played", select operator > and value 3

5) Segment settings. You can apply following settings for each segment. They will apply to all users matched to that segment.

  • Disable networks - Allows you to disable any network for an ad type it supports.
  • Min pricefloor - Allows you to set minimum price floor for each ad type. Ads with eCPM lower than price floor will not be filled.
  • Overriden eCPM - Allows you to override eCPM of each network for ad type. High eCPM(100+) will ensure that the network will be at the top of the waterfall and get the first fill. Low eCPM (close to 0) will ensure that the network acts as backfill.

If you have no segments all users will be matched to hidden default segment.

If you have multiple segments, their order is important. Only the first segment in which rules are matched to the user will apply. All of the rest will be ignored.

Placements

Appodeal SDK allows you to tag each impression with different placement.

To check if an impression is available for a given placement, use:

Appodeal.canShowAd(.interstitial, forPlacement: "placement")

To show an ad with placement, you have to call show method like this:

Appodeal.showAd(.interstitial, forPlacement: "placement", rootViewController: controller)

Get reward for placement

Appodeal.reward(forPlacement: "placement")

Placement can be used for separating your revenue by placement in our dashboard and determining which placement earns you more money.

Also you can configure your impression logic for each placement. You can use the following Placement settings:

  • Disable ads - disables ads completely for that placement.
  • Disable as types - disables specific ad type for a placement. If you integrated to show Appodeal.INTERSTITIAL | Appodeal.REWARDED_VIDEO you can disable interstitials or rewarded video for the placement.
  • Reward - you can set a reward amount and name which will be passed in onRewardedVideoFinished callback for all videos shown with this placement.
  • Impression/Refresh period - you can set the impression period (in seconds) for interstitials and rewarded video shown with the placement. If the period between two impression is less than the impression period, the second impression will not be shown and the Appodeal.show method will return false. For banners and MRECs you can set their refresh period.
  • Min pricefloor - Allows you to set minimum price floor for each ad type. Ads with eCPM lower than price floor will not be shown and Appodeal.show method will return false.

Placements can only be used as part of existing segment. If you only want to use placements, create one segment for each platform without any rules and match rule ALL. All of your users will match to it.

If you have no placement, or call Appodeal.show with placement that do not exist or without placement in your segment, the impression will be tagged with 'default' placement and its settings will be applied

IMPORTANT: placements affect ONLY ad presentation, not loading or caching.

You can check more examples here

Advanced Features

Add this in you info.plist

<key>NSLocationWhenInUseUsageDescription</key>
<string>Advertising</string>
<key>NSCalendarsUsageDescription</key>
<string>Advertising</string>

If your app is designed for kids you can disable sending user data to ad networks by following method (IMPORTANT: use it before SDK initialisation):

Appodeal.setChildDirectedTreatment(true)

Enabling test mode (test mode allows you to show our test ads with 100% fillrate)

Appodeal.setTestingEnabled(true)

Log level

Appodeal.setLogLevel(.verbose)
APDLogLevelOff Logs off
APDLogFlagError Only error messages
APDLogLevelWarning Warning and error messages
APDLogLevelDebug Debug messages
APDLogLevelInfo Erorr, warning and information messages
APDLogLevelVerbose All sdk messages

Banner smart size (allows banner to resize automatically to fit device screen)

//for top/bottom banners
Appodeal.setSmartBannersEnabled(true)

//for bannerView
bannerView.smartBannersEnabled = true

Banner background (creates a gray background view for banner ad)

//for top/bottom banners
Appodeal.setBannerBackgroundVisible(true)

//for bannerView
bannerView.backgroundVisible = true

Banner animation

//for top/bottom banners
Appodeal.setBannerAnimationEnabled(true)

//for bannerView
bannerView.bannerAnimationEnabled = true

Checking if ad is loaded

Appodeal.isReadyForShow(with: .interstitial)
Appodeal.isReadyForShow(with: .rewardedVideo)

Caching ads with adType

Appodeal.cacheAd(.interstitial)
Appodeal.cacheAd(.banner)
Appodeal.cacheAd(.rewardedVideo)

Enabling or disabling automatic caching (should be used before SDK initialising)

Appodeal.setAutocache(true, types: .interstitial)
Appodeal.setAutocache(true, types: .banner)
Appodeal.setAutocache(true, types: .rewardedVideo)

Disabling networks for ad types (should be used before SDK initialising)

Appodeal.disableNetwork(for: .banner, name: "NETWORK_NAME")
Appodeal.disableNetwork(for: .nativeAd, name: "NETWORK_NAME")
Appodeal.disableNetwork(for: .MREC, name: "NETWORK_NAME")
Appodeal.disableNetwork(for: .interstitial, name: "NETWORK_NAME")
Appodeal.disableNetwork(for: .rewardedVideo, name: "NETWORK_NAME")

Setting location tracking (should be used before SDK initialising)

Appodeal.setLocationTracking(true)

You can track inApp purchases by using method track(inAppPurchase amount: NSNumber!, currency: String!). Example:

APDSdk.shared().track(inAppPurchase: NSNumber(value: 123), currency: "USD")

Setting User Data

Our SDK provides targeting for any included network. You can set user settings at any time by using the following class method:

Name of field Type Description
func setUserId String user ID
func setUserEmail String user email
func setUserBirthday Date user birthday
func setUserAge Integer user age
func setUserGender AppodealUserGender user gender
func setUserOccupation AppodealUserOccupation user occupation
func setUserRelationship AppodealUserRelationship user relationship
func setUserAlcoholAttitude AppodealUserAlcoholAttitude user alcohol altitude
func setUserSmokingAttitude AppodealUserSmokingAttitude user smoking altitude
func setUserInterests String user interests
Appodeal.setUserId("userId")
Appodeal.setUserEmail("dt@email.net")
Appodeal.setUserBirthday([Date date])
Appodeal.setUserAge(25)
Appodeal.setUserGender(.male)
Appodeal.setUserOccupation(.work)
Appodeal.setUserRelationship(.other)
Appodeal.setUserSmokingAttitude(.neutral)
Appodeal.setUserAlcoholAttitude(.neutral)
Appodeal.setUserInterests("other")

Versions of SDKs inside Appodeal framework

Ad network nameVersionBitcode support
AdColony3.2.1YES
AmazonAds2.2.15.1YES
AppLovin4.3.1YES
Chartboost7.0.1YES
FBAudienceNetwork4.24.0 YES
Flurry8.0.1 YES
Google Mobile Ads7.24.0 YES
InMobi6.2.1 YES
IronSource6.6.8 YES
StartApp3.4.3 YES
Tapjoy11.11.0 YES
UnityAds2.1.0 YES
Vungle5.1.0 YES
YandexMobileAds2.7.2 YES
myTarget4.6.16 YES
MoPub4.15.0 YES

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

On the "Advertising Identifier" section:

  • Turn-on "Yes" on the right pane
  • Opt-in the "Serve advertisements within the app" checkbox
  • Opt-in the confirmation checkbox under "Limit Ad tracking setting in iOS"
Idfa