Home > Software design >  Swift Interstitial is working, but once the ad is closed, I am still on gameboardVC. I need it to tr
Swift Interstitial is working, but once the ad is closed, I am still on gameboardVC. I need it to tr

Time:02-01

// MARK: - GAMEBOARD CONTROLLER class GameBoard3: UIViewController,GADBannerViewDelegate,GADFullScreenContentDelegate

{ }

override func viewDidLoad() { super.viewDidLoad()

// MARK: - GAME OVER func gameOver() {

    // Save Best Score
    if bestScore <= score3 {
        bestScore = score3
        UserDefaults.standard.set(bestScore, forKey: "bestScore")
        UserDefaults.standard.synchronize()
    }
    
    // Play a sound
    soundName3 = "gameOver"
    playWav()
  
    
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
       let goVC = storyboard.instantiateViewController(withIdentifier: "GameOverVC3")
       //self.present(myVC, animated: true, completion: nil)
    if interstitial != nil {
      interstitial!.present(fromRootViewController: self)
    } else {
        self.present(goVC, animated: true, completion: nil)
    }
    }

CodePudding user response:

if interstitial != nil is true you will never call

self.present(goVC, animated: true, completion: nil)

i dont know if it will work to just copy the line too under

interstitial!.present(fromRootViewController: self)

or if you some how have to detect when the user dismisses the add

CodePudding user response:

Have you tried to check delegate method adDidDismissFullScreenContent(_:) ?

In this callback you can whatever you want, for example redirect user to another screen.

Check the AdMob docs here: Register for Callbacks

  •  Tags:  
  • Related