RichieAdsController
@MainActor
public final class RichieAdsController
RichieAdsController
is the main interface for loading ads with Richie SDK.
If possible, you should be using this class instead of RichieAds
. RichieAds
does not force usage from the main thread but strongly recommends it; this class
forces the issue and defines itself to work on the main actor.
If you create a RichieAdsController
, yourself, you should call invalidate()
on it
before relinquishing the last reference. If you use Richie
to create it, it keeps
a reference to the RichieAdsController
it creates and you should use its invalidate
method instead.
-
Initialize
RichieAdsController
.Declaration
Swift
@MainActor public convenience init( appIdentifier: String )
-
This method should be called before relinquishing last reference to a
RichieAdsController
instance. It allowsRichieAds
to nicely shut down and clean up.Declaration
Swift
@MainActor public func invalidate()
-
Global persisted parameters can be used by ad creatives (using JavaScript API) to query global state. This gives creatives the opportunity to communicate with each other, using simple string values. For example, one creative can set a value for a key when some action has been performed by the user, and then another creative can know that this event has occurred.
Note
Parameters are retained only for a limited duration. They will be cleaned after 30 days of inuse.Declaration
Swift
@MainActor func setGlobalPersistedParameter(key: String, value: String?)
-
Returns value for a global persisted parameter.
Declaration
Swift
@MainActor func globalPersistedParameterValue(key: String) -> String?
-
This method exists for backwards compatibility, but should be considered soft deprecated. See
nextFlightForSlots(slotIdentifiers:)
for a direct replacement.Declaration
Swift
@MainActor func nextFlightForSlot(slotIdentifier: String) -> RichieAdsSlotAdFlight?
-
A variable number of arguments variant of
nextFlightForSlots(slotIdentifiers:)-1gsry
. See that method’s documentation for details.Declaration
Swift
@MainActor func nextFlightForSlots(slotIdentifiers: String...) -> RichieAdsSlotAdFlight?
-
Returns an ad flight when slot display logic indicates it’s time to show an ad. For example, this method might be called for each page view in an app, but it could return an instance once in three calls.
Instances returned from this method must be either shown to the user or released as quickly as possible, when it is known that the flight will not be shown to the user. This allows internal counters and logic to reserve view counts, but return them back to the slot when a flight won’t be shown.
The slot identifiers are attempted in order, and the first non-nil flight is returned.
See also
nextFlightForSlots(slotIdentifiers:)
if you prefer an interface that accepts a variable number of arguments.Declaration
Swift
@MainActor func nextFlightForSlots(slotIdentifiers: [String]) -> RichieAdsSlotAdFlight?
-
Create an ad view from
adFlight
.Declaration
Swift
@MainActor func view( frame: CGRect, adFlight: RichieAdsSlotAdFlight, delegate: any RichieAdsViewDelegate, parameters: [String: String]? = nil ) -> RichieAdsView?