Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.adrop.io/llms.txt

Use this file to discover all available pages before exploring further.

GitHub Repository

iOS SDK Example

iOS SDK example project

Example Project Structure

We provide examples in three different approaches: SwiftUI, UIKit, and Objective-C.
Available in the adrop-ads-example-ios-swiftUI/ folder.This is an example implementing ads with SwiftUI-based declarative UI.

How to Run Examples

1

Clone the repository

git clone https://github.com/OpenRhapsody/adrop-ads-example-ios.git
cd adrop-ads-example-ios
2

Install dependencies

pod install
3

Open workspace

open adrop-ads-example-ios.xcworkspace
You must open .xcworkspace, not .xcodeproj.
4

Run

  1. Select a simulator or real device
  2. Click Run (⌘R)
The example project uses test unit IDs, so you can run it immediately without any additional configuration.

Key Example Code

import SwiftUI
import AdropAds

struct BannerExample: View {
    var body: some View {
        AdropBannerRepresented(unitId: "PUBLIC_TEST_UNIT_ID_320_50")
            .frame(width: 320, height: 50)
    }
}

Interstitial Ad (UIKit)

import UIKit
import AdropAds

class InterstitialViewController: UIViewController, AdropInterstitialAdDelegate {
    var interstitialAd: AdropInterstitialAd?

    override func viewDidLoad() {
        super.viewDidLoad()
        interstitialAd = AdropInterstitialAd(unitId: "PUBLIC_TEST_UNIT_ID_INTERSTITIAL")
        interstitialAd?.delegate = self
        interstitialAd?.load()
    }

    func onAdReceived(_ ad: AdropInterstitialAd) {
        if ad.isLoaded {
            ad.show(fromRootViewController: self)
        }
    }

    func onAdFailedToReceive(_ ad: AdropInterstitialAd, _ errorCode: AdropErrorCode) {
        print("Failed: \(errorCode)")
    }
}

Interstitial Ad (Objective-C)

@import AdropAds;

@interface InterstitialViewController () <AdropInterstitialAdDelegate>
@property (nonatomic, strong) AdropInterstitialAd *interstitialAd;
@end

@implementation InterstitialViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.interstitialAd = [[AdropInterstitialAd alloc] initWithUnitId:@"PUBLIC_TEST_UNIT_ID_INTERSTITIAL"];
    self.interstitialAd.delegate = self;
    [self.interstitialAd load];
}

- (void)onAdReceived:(AdropInterstitialAd *)ad {
    if (ad.isLoaded) {
        [ad showFromRootViewController:self];
    }
}

- (void)onAdFailedToReceive:(AdropInterstitialAd *)ad :(AdropErrorCode)errorCode {
    NSLog(@"Failed: %ld", (long)errorCode);
}

@end

User Event Tracking

import AdropAds

class EventTrackingExample {
    func trackEvents() {
        // Simple event - no parameters
        AdropMetrics.sendEvent(name: "app_open")

        // Event with parameters
        AdropMetrics.sendEvent(name: "view_item", params: [
            "item_id": "SKU-123",
            "item_name": "Widget",
            "item_category": "Electronics",
            "price": 29.99
        ])

        // Multi-item event (purchase)
        AdropMetrics.sendEvent(name: "purchase", params: [
            "tx_id": "tx_123",
            "currency": "KRW",
            "items": [
                ["item_id": "A", "item_name": "Product A", "price": 100, "quantity": 1],
                ["item_id": "B", "item_name": "Product B", "price": 200, "quantity": 2]
            ]
        ])

        // Sign up event
        AdropMetrics.sendEvent(name: "sign_up", params: [
            "method": "google"
        ])
    }
}

Getting Started

SDK installation and initialization

Banner Ad

Banner ad implementation

Interstitial Ad

Interstitial ad implementation

Reference

API reference