i have two view controllers imageViewController and InfoViewController. i want my ad to show when the user click on back button from InfoViewController
class imageViewController: UIViewController , GADInterstitialDelegate {
var interstitial: GADInterstitial!
override func viewDidLoad() {
self.interstitial = self.createAndLoadInterstitial()
super.viewDidLoad()
}
func createAndLoadInterstitial() -> GADInterstitial {
let interstitial: GADInterstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
interstitial.delegate = self
let request = GADRequest()
interstitial.loadRequest(request)
print("req sent")
return interstitial
}
func interstitialDidReceiveAd(ad: GADInterstitial!) {
if (interstitial.isReady) {
print("ad ready")
interstitial.presentFromRootViewController(self)
}}
func interstitialDidDismissScreen(interstitial: GADInterstitial) {
}
How should i call it with back button click from infoViewController to ImageViewCroller. i also failed to solve this problem with global variable since i am new to iOS