Docs

iOS SDK

Swift Package for iOS. Banner, interstitial, rewarded video — with server-side verified rewards over HMAC.

Install via Swift Package Manager

Add the package URL in Xcode. Pinned semver — patch upgrades are safe.

Xcode → Add Packages
// File → Add Packages…
// Paste this URL, pick "Up to Next Major Version: 0.1.0".
https://mpwa.to/sdk-ios.git

Minimum iOS 15.0 · Swift 5.9 · Xcode 15.

Configure once at app launch

Call MpwaAds.shared.configure() from your @main App so every ad shares one HTTP client + signing key.

App.swift
import MpwaAds

@main
struct YourApp: App {
    init() {
        MpwaAds.shared.configure(
            publisherId: "YOUR_PUBLISHER_ID",
            adServerUrl: URL(string: "https://ads.mpwa.to")!
        )
    }

    var body: some Scene {
        WindowGroup { ContentView() }
    }
}

Rewarded video — full flow

Two-step lifecycle: load() then show(from:). Reward fires only after the user watches past skip_after_sec; we POST a signed grant to your SSV endpoint in parallel.

RewardedFlow.swift
import MpwaAds
import UIKit

class RewardedFlow: NSObject, RewardedVideoAdDelegate {
    private let ad: RewardedVideoAd

    init(adUnitId: UInt64) {
        // The ad-unit ID comes from /dashboard/apps → your app → ad units.
        self.ad = RewardedVideoAd(adUnitId: adUnitId)
        super.init()
        self.ad.delegate = self
    }

    func loadAndShow(from vc: UIViewController) {
        Task {
            do {
                try await ad.load()
                ad.show(from: vc)
            } catch {
                print("rewarded load failed: \(error)")
            }
        }
    }

    // MARK: RewardedVideoAdDelegate
    func rewardedVideo(_ ad: RewardedVideoAd, didReward reward: Reward) {
        // Credit reward.amount of reward.currency to the user. Server-side
        // verification happens automatically — your SSV callback (set in
        // /dashboard/settings → Rewarded SSV) gets a signed POST in parallel.
        print("granted \(reward.amount) \(reward.currency) for impression \(reward.impressionId)")
    }
    func rewardedVideoDidDismiss(_ ad: RewardedVideoAd) {
        print("user closed without completing")
    }
}

Set the SSV callback URL on /dashboard/settings → Rewarded SSV before going live. Without it the SDK still grants, but you have no server-side signal to credit the user authoritatively.