Reputation: 165
I implement the google interstitial adv. in my app and it is working correctly. But it is not hide status bar and it say in console:
Status bar could not be hidden for full screen ad. Ensure that your app is configured to allow full screen ads to control the status bar. For example, consider whether you need to set the childViewControllerForStatusBarHidden property on your ad's rootViewController.
I could not find any way to fix it. How can I fix it and hide the status bar. Because sometimes close icon is under status bar and it is not working.
My code:
func showInterstitial(){
let interstitalId = Advertisement.sharedInstance.interstitialAddUnit
let request = GADRequest()
GADInterstitialAd.load(
withAdUnitID: interstitalId, request: request
) { (ad, error) in
if let error = error {
debugPrint("Failed to load interstitial ad with error: \(error.localizedDescription)")
return
}
self.interstitial = ad
self.interstitial?.fullScreenContentDelegate = self
if let ads = self.interstitial {
ads.present(fromRootViewController: self)
} else {
debugPrint("Ad wasn't ready")
}
}
}
Upvotes: 0
Views: 407
Reputation: 200
you have to set prefersStatusBarHidden
value as true inside your view view controller
override var prefersStatusBarHidden: Bool {
return true
}
Upvotes: 0