Skip to main content

Integrate Interstitial and Rewarded Ads

Here you will find the guide to implement and use the Attrackt iOS Framework SDK

Ads Flow Methods

Ads are being loaded into their specific Placement, Placements has an ID and are being setup on the dashboard.
After setting a placement and connecting a Demand to it, all you have to do is calling the loadPlacement function after the AttracktDelegate init success method was called.



Method to load multiple or single placement using the placement id
loadPlacements(placementId: [String])


Example of calling loadPlacements
AttracktIO.loadPlacements(["before_game_starts","after_char_is_dead","on_stage_completed"])


info

There is no need to call the loadPlacements each time you want to present an ad. just once while loading the app after the sdk notifies its loaded correctly



After calling the loadPlacements method, you gone call the following method in order to present the ad for that specific placement

Example of calling showAd
AttracktIO.playAd(placementId: "before_game_starts")

Ads Delegate

In order to handle AD life cycle like knowing when id appeared or disappeared or when to give the user his prize for watching the rewarded ad all the way or clicking a banner We have the delegate:

AttracktAdsDelegate

When implemented:

class ViewController: UIViewController, AttracktDelegate, AttracktAdsDelegate {

After implementing the delegate you sohuld go and set the delegate with the sdk:

setAdsDelegate(adsDelegate: AttracktAdsDelegate)

Every function whithin the delegate will always return the following paramters:

- adType: AttracktAdType Banner, Rewarded, Interstitial
- advertiser: AttracktSupportedAdvertisers Return the advertiser that presented the ad e.g Attrackt, AppLovin
- placement: String Return the placement the belongs to the advertiser
- attracktPlacement: String Return the placement which was used with Attrackt in order to laod the ad

The ads delegate containts the methods:

On ad loaded and ready to play
onAdDidLoad(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
On ad impression which means it was displayed on the screen properly
onAdDidShow(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
Something went wrong with loading the ad and handle it
onAdDidFailToLoadWithError(adType: AttracktAdType, error: String, placement: String, attracktPlacement: String)
On ad clicked being called when user tap the ad
onAdClicked(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
When ad is done or gone from the screen. usually you wold use it to check the state and respond accordingly
onAdDisappear(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String , state: AttracktAdFinishedState)