I want to show a Reward Ad (Google AdMob) in my swift app. (XCode 11.4, Swift 5, Storyboard), but whenever I load the ad it shows the following error message in the console:
Error Domain=com.google.admob Code=5
"Request Error: The Google Ad request was unable to be fulfilled before a timeout occurred."
UserInfo={NSLocalizedDescription=Request Error: The Google Ad request was unable to be fulfilled before a timeout occurred., gad_response_info=<GADResponseInfo: 0x6000030f8090>}
I basically followed the tutorial from Google AdMob Tutorial.
- I added my GADApplicationIdentifier to the
info.plist
- In the AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GADMobileAds.sharedInstance().start(completionHandler: nil)
}
- In the ViewController I followed the steps from the new RewardAd Tutorial and basically copied and pasted it, except for replacing the AdId with my own (I'm running it in a Simulator, so using own AdID's should not be a problem if I understood correctly...)
This is where it fails:
override func viewDidLoad() {
super.viewDidLoad()
rewardedAd = GADRewardedAd(adUnitID: adId)
rewardedAd?.load(GADRequest()) { error in
if let error = error {
print("Error while loading ad: \(error.description)")
// Timeout occurs here!!!
} else {
if self.rewardedAd?.isReady == true {
self.rewardedAd?.present(fromRootViewController: self, delegate:self)
}
}
}
}
Any idea why I get the timeout?
Note:
- I also created a sample SwiftUI app with the same rewarded app structure, which also gets the timeout
- and yes my internet connection works just fine
- I tried the example AdIds from AdMob too, then I get the following error:
Error while loading ad: Error Domain=com.google.admob Code=1
"Request Error: No ad to show."
UserInfo={NSLocalizedDescription=Request Error: No ad to show., gad_response_info=<GADResponseInfo: 0x6000018f4d80>}
I used in the 'info.plist' : ca-app-pub-3940256099942544~1458002511
and for the AdID : ca-app-pub-3940256099942544/1712485313
both from the above mentioned tutorial pages from Google.