Skip to main content

Overview

Use the Adrop iOS SDK to display various ad formats in your app.

Supported Ad Formats

FormatDescription
BannerRectangular ads displayed in a portion of the screen
NativeAds that can be customized to match your app UI
InterstitialFull-screen ads that cover the entire screen
RewardedVideo ads that provide rewards upon completion
PopupAds displayed as popups at specific moments
SplashAds displayed with your logo when the app starts

Requirements

  • iOS 13.0 or higher
  • Xcode 14.1 or higher
  • Swift 5.0 or higher

Prerequisites

1. Add adrop_service.json File

1

Download File

Download the adrop_service.json file from AdControl Console > Admin > App.
2

Add to Project

Add the downloaded file to your Xcode project root.
3

Check Targets

When adding the file, ensure that all targets are selected.
The SDK will not function properly without the adrop_service.json file.

2. Check Unit ID

Check the unit ID for your ad placement in the Ad Unit tab of the console.

Installation

  1. In Xcode, select File > Add Package Dependencies…
  2. Enter the package URL:
https://github.com/OpenRhapsody/adrop-ads-pod
  1. Click Add Package

CocoaPods

  1. Create Podfile if it doesn’t exist:
pod init
  1. Add to Podfile:
Podfile
pod 'adrop-ads'
  1. Install:
pod install --repo-update
  1. Open the project with .xcworkspace file

Initialization

Initialize the SDK in application(_:didFinishLaunchingWithOptions:) of your AppDelegate.
import AdropAds

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // Initialize SDK
        Adrop.initialize(production: false, targetCountries: [], useInAppBrowser: false)
        Adrop.setTheme(.auto)

        return true
    }
}

Initialization Parameters

ParameterTypeDefaultDescription
productionBoolfalseProduction mode. Set to true when deploying
targetCountries[String][]List of target country codes (ISO 3166 alpha-2)
useInAppBrowserBoolfalseWhether to use in-app browser
Make sure to set production: true before deployment. If deployed with false, ads will not be displayed.

User Configuration

Set UID

Set a user identifier for targeted advertising.
Adrop.setUID("user_123")
Set the UID before entering the ad placement for targeted ads to work properly.

Set Theme

Set the theme for ads that support dark mode. Must be set after calling initialize().
// Light mode
Adrop.setTheme(.light)

// Dark mode
Adrop.setTheme(.dark)

// Follow system settings (recommended)
Adrop.setTheme(.auto)
auto mode automatically detects system dark mode settings. When the theme changes, the splash ad cache is automatically reset.

Handle deep links when the app is launched via external links.
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    guard let url = URLContexts.first?.url else { return }
    Adrop.handleDeepLink(url: url)
}

Test Unit IDs

Use test unit IDs during development. Replace with actual unit IDs before production deployment.
FormatTest Unit ID
Banner (320x50)PUBLIC_TEST_UNIT_ID_320_50
Banner (320x100)PUBLIC_TEST_UNIT_ID_320_100
Carousel BannerPUBLIC_TEST_UNIT_ID_CAROUSEL
Banner Video (16:9)PUBLIC_TEST_UNIT_ID_BANNER_VIDEO_16_9
Banner Video (9:16)PUBLIC_TEST_UNIT_ID_BANNER_VIDEO_9_16

Native Ads

FormatTest Unit ID
Native (Image)PUBLIC_TEST_UNIT_ID_NATIVE
Native Video (16:9)PUBLIC_TEST_UNIT_ID_NATIVE_VIDEO_16_9
Native Video (9:16)PUBLIC_TEST_UNIT_ID_NATIVE_VIDEO_9_16

Interstitial/Rewarded Ads

FormatTest Unit ID
InterstitialPUBLIC_TEST_UNIT_ID_INTERSTITIAL
RewardedPUBLIC_TEST_UNIT_ID_REWARDED
FormatTest Unit ID
Popup (Bottom)PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM
Popup (Center)PUBLIC_TEST_UNIT_ID_POPUP_CENTER
Popup Video Bottom (16:9)PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM_VIDEO_16_9
Popup Video Bottom (9:16)PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM_VIDEO_9_16
Popup Video Center (16:9)PUBLIC_TEST_UNIT_ID_POPUP_CENTER_VIDEO_16_9
Popup Video Center (9:16)PUBLIC_TEST_UNIT_ID_POPUP_CENTER_VIDEO_9_16

Splash Ads

FormatTest Unit ID
SplashPUBLIC_TEST_UNIT_ID_SPLASH

Error Codes

Main error codes returned when ad loading fails.
Error CodeDescription
ERROR_CODE_AD_NO_FILLNo available ads to display
ERROR_CODE_NETWORKNetwork connection failed
ERROR_CODE_INVALID_UNITInvalid unit ID
ERROR_CODE_INITIALIZESDK initialization required
See Reference for detailed error codes.

Table of Contents