Interstitial Ads
First of all, you need to create a InterstitialAdController object and init it (with your application context in parameter). After this, you have two possibilities:
  • Display as quickly as possible the ad after loading it. For this, you can simply call the method Adstronomic.loadAndShow with the app context and the ad object as parameters.
  • Just load the ad in the background by calling Adstronomic.loadInterstitial(). And, when you want to show the ad (after a specific event - For example: click on a button) you can do it with self.present of your view.
So, for example:
Swift
1
var interstitialAd: InterstitialAdController?
2
​
3
interstitialAd = InterstitialAdController.initializeObject()
4
Adstronomic.loadAndShow(view: self, ad: interstitialAd!)
Copied!
or
Swift
1
var interstitialAd: InterstitialAdController?
2
​
3
Adstronomic.loadInterstitial()
4
interstitialAd = InterstitialAdController.initializeObject()
5
​
6
...
7
​
8
// Call when a button is pressed for example
9
if interstitialAd != nil {
10
self.present(interstitialAd!, animated: true, completion: nil)
11
}
Copied!

Listener

If you want to unlock reward or detect when an error occurred (ads not available because of internet connection issue), you can add a listener in order to execute your custom logic. For this, see the following example:
Swift
1
interstitialAd?.setOnAdLoadFailed {
2
// Your code here
3
}
4
​
5
interstitialAd?.setOnAdLoaded {
6
// Your code here
7
}
8
​
9
interstitialAd?.setOnAdClosed {
10
print("Interstitial Ad Closed!")
11
}
12
​
13
interstitialAd?.setOnAdShown {
14
// Your code here
15
}
Copied!
Each event is self explanatory. For example, if you want to give a reward to the player, execute this code in setOnAdClosed.
Copy link
Contents
Listener