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.
- Swift
- Objective-C
loadPlacements(placementId: [String])
loadPlacements(placementId: [String])
- Swift
- Objective-C
AttracktIO.loadPlacements(["before_game_starts","after_char_is_dead","on_stage_completed"])
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
- Swift
- Objective-C
AttracktIO.playAd(placementId: "before_game_starts")
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:
- Swift
- Objective-C
onAdDidLoad(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
onAdDidLoad(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
- Swift
- Objective-C
onAdDidShow(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
onAdDidShow(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
- Swift
- Objective-C
onAdDidFailToLoadWithError(adType: AttracktAdType, error: String, placement: String, attracktPlacement: String)
onAdDidFailToLoadWithError(adType: AttracktAdType, error: String, placement: String, attracktPlacement: String)
- Swift
- Objective-C
onAdClicked(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
onAdClicked(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String)
- Swift
- Objective-C
onAdDisappear(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String , state: AttracktAdFinishedState)
onAdDisappear(adType: AttracktAdType, advertiser: AttracktSupportedAdvertisers, placement: String, attracktPlacement: String , state: AttracktAdFinishedState)