Files
Peter Porfy 6d64d3c8de feat(ads): dispatch checkpoint ad presentation by format (#7786)
* feat(ads): dispatch checkpoint ad presentation by format

Ad units are format-locked, so the SDK needs to know which AdMob loader a
checkpoint ad step's unit belongs to. The backend now requires ad_format
on the step; core surfaces it on ResolvedAdStep, RevenueCatUI threads it
through AdPresentationParams, and the AdMob adapter replaces its three
per-format presenters with one AdMobPresenter that dispatches on it and
fails fast on formats it does not implement.

* refactor: presenter composition

* fix: use renamed InviteOnlyCheckpointsApi SPI

* test(ads): assert on shown and failed ad executions

The ad outcome classes are gone, so the format-aware presenter reports
shown for every format and the tests match the execution cases.

* test(ads): match failed ad executions and the ad format param

Claude-Session: https://claude.ai/code/session_01Gj5NLpaCp45dfxDVR5rScP

* fix(ads): keep the ad params initializer internal-only

The adapter tests are the only external caller, so the init is SPI
rather than public, as the no_new_public_inits rule requires. Also
passes the ad format in the missing-presenter behavior test.

Claude-Session: https://claude.ai/code/session_01Gj5NLpaCp45dfxDVR5rScP

* fix(ads): mark AdMob presenter inits as SPI for lint

Claude-Session: https://claude.ai/code/session_01Gj5NLpaCp45dfxDVR5rScP

* test(api): cover AdPresentationParams.adFormat in the RevenueCatUI API tester
2026-11-02 17:49:58 +01:00

39 lines
1.2 KiB
Swift

//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// ResolvedAdStep.swift
//
// Created by RevenueCat.
import Foundation
/// An ad step resolved for a checkpoint, with no RevenueCat-managed UI to present. A registered ad
/// presenter decides how to show it.
@_spi(Internal) public struct ResolvedAdStep: Equatable, Sendable {
/// Identifies the ad to load for this step, in whatever form ``mediator`` expects (an AdMob ad unit id, for
/// example).
public let adIdentifier: String
/// The mediation network configured to serve ``adIdentifier``.
public let mediator: MediatorName
/// The ad format ``adIdentifier`` was created for. Ads are format-locked, so a presenter must load
/// this ad through the matching format's loader.
public let adFormat: AdFormat
/// Creates a resolved ad step.
@_spi(Internal) public init(adIdentifier: String, mediator: MediatorName, adFormat: AdFormat) {
self.adIdentifier = adIdentifier
self.mediator = mediator
self.adFormat = adFormat
}
}