2

Swift アプリでリワード広告 (Google AdMob) を表示したい。(XCode 11.4、Swift 5、ストーリーボード)、広告を読み込むたびに、コンソールに次のエラー メッセージが表示されます。

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>}

基本的にGoogle AdMob Tutorialのチュートリアルに従いました。

  1. GADApplicationIdentifierを_info.plist
  2. AppDelegate で:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    GADMobileAds.sharedInstance().start(completionHandler: nil)
}
  1. ViewController では、新しいRewardAd チュートリアルの手順に従い、基本的にそれをコピーして貼り付けましたが、AdId を自分のものに置き換えました (シミュレータで実行しているので、正しく理解していれば、独自の AdID を使用しても問題ありません)。 ...)

これは失敗する場所です:

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)
            }
        }
    }
}

タイムアウトが発生する理由は何ですか?

ノート:

  • また、タイムアウトを取得する同じリワード アプリ構造を持つサンプル SwiftUI アプリも作成しました。
  • はい、私のインターネット接続は問題なく動作します
  • AdMob のサンプル AdIds も試してみましたが、次のエラーが発生しました。
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>}

私は 'info.plist' で使用しました:ca-app-pub-3940256099942544~1458002511 と AdID :ca-app-pub-3940256099942544/1712485313両方とも上記の Google のチュートリアル ページから。

4

1 に答える 1