jwarris91
jwarris91

Reputation: 952

Preventing Segue Until User Dismisses Ad?

I am integrating interstital ads to a few segues in my app.

Issue is the interstital loads and then is instantly voided by the segue triggering.

Is there a method so pause the function to not run the segue until the advert is closed? Thats the only way I can think to resolve this. Code is below:

@IBAction func closeExerciseDetails(_ sender: Any) {
    if (self.interstitial.isReady) {
        self.interstitial.present(fromRootViewController: self)
        self.interstitial = self.createAd()
    }
    self.performSegue(withIdentifier: "unwindToExercisesSegue", sender: self)
}

EDIT: New code that isnt working...

@IBAction func closeExerciseDetails(_ sender: Any) {
    if (self.interstitial.isReady) {
        self.interstitial.present(fromRootViewController: self)
        self.interstitial = self.createAd()
    }
}

func interstitialDidDismissScreen(_ ad: GADInterstitial) {
    self.performSegue(withIdentifier: "unwindToExercisesSegue", sender: self)
}

Upvotes: 0

Views: 105

Answers (1)

Yasir Ali
Yasir Ali

Reputation: 154

There's a delegate for this:

- (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial {
}

You can just perform the segue in this delegate.

Upvotes: 3

Related Questions