Reputation: 1272
I'v been trying to deal with this problem for a good while but cant figure out how to fix it.
Currently I'v added Admob to my project and the interstitial's are displaying but when I exit the interstitial it returns me to my previous VC (where the interstitial instance is made).
As you can see below im trying to add them to my Tabbar functions. But the segue never happens nor do the alerts show before the interstitial. I wanted to show the the ad then segue to the VC. And I want the user to see the alert and press "OK" before seeing the interstitial.
Any help would be awesome!
//TabBar Functions
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
if (item.tag == 1) {
if (self.interstitial.isReady) {
self.interstitial.presentFromRootViewController(self)
}
self.performSegueWithIdentifier("showStore", sender: nil)
} else if (item.tag == 2) {
let alert = UIAlertController(title: "Coming Soon!", message: "Loadout", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Got It!", style: .Default, handler: nil))
if (self.interstitial.isReady) {
self.interstitial.presentFromRootViewController(self)
}
self.presentViewController(alert, animated: true, completion: nil)
return
} else if (item.tag == 3) {
let alert = UIAlertController(title: "Coming Soon!", message: "God's Tower", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Got It!", style: .Default, handler: nil))
if (self.interstitial.isReady) {
self.interstitial.presentFromRootViewController(self)
}
self.presentViewController(alert, animated: true, completion: nil)
return
}
}
Upvotes: 2
Views: 497
Reputation: 18898
Set your GADInterstitial
's delegate and then segue once the ad has been dismissed.
// Add this where you're creating your GADInterstitial
interstitial.delegate = self
func interstitialDidDismissScreen(ad: GADInterstitial!) {
// Segue to your view controller here
}
For a complete list of ad events refer to GADInterstitialDelegate implementation.
Upvotes: 4