質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

解決済

1回答

1271閲覧

Xcode Swiftのバナー広告が表示されない

komekome0101

総合スコア14

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2021/04/05 09:11

swift

1import UIKit 2import GoogleMobileAds 3class QuizViewController: UIViewController { 4 5 @IBOutlet weak var judgeImageView: UIImageView! 6 var BannerView: GADBannerView! 7 8 override func viewDidLoad() { 9 super.viewDidLoad() 10 11 BannerView = GADBannerView(adSize: kGADAdSizeBanner) 12 addBannerViewToView(BannerView) 13 BannerView.adUnitID = "ca-app-pub-7967816978520304/2883950888" 14 BannerView.rootViewController = self 15 BannerView.load(GADRequest()) 16 } 17 18 func addBannerViewToView(_ bannerView: GADBannerView) { 19 bannerView.translatesAutoresizingMaskIntoConstraints = false 20 view.addSubview(bannerView) 21 view.addConstraints( 22 [NSLayoutConstraint(item: bannerView, 23 attribute: .bottom, 24 relatedBy: .equal, 25 toItem: view.safeAreaLayoutGuide, 26 attribute: .bottom, 27 multiplier: 1, 28 constant: 0), 29 NSLayoutConstraint(item: bannerView, 30 attribute: .centerX, 31 relatedBy: .equal, 32 toItem: view, 33 attribute: .centerX, 34 multiplier: 1, 35 constant: 0) 36 ]) 37 } 38 39 40}

info.listには

GADApplicaionIdentifier:アプリID
GADIsAdManagerApp:true

がセットされています。
広告の初期化

swift

1import UIKit 2import GoogleMobileAds 3@main 4class AppDelegate: UIResponder, UIApplicationDelegate { 5 6 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 7 // Override point for customization after application launch. 8 GADMobileAds.sharedInstance().start(completionHandler: nil) 9 return true 10 } 11 12 // MARK: UISceneSession Lifecycle 13 14 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 15 // Called when a new scene session is being created. 16 // Use this method to select a configuration to create the new scene with. 17 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 18 } 19 20 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { 21 // Called when the user discards a scene session. 22 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 23 // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 24 } 25 26 27}

Podfile

1target 'SampleQuiz' do 2 use_frameworks! 3 4 pod 'Google-Mobile-Ads-SDK' 5 6end

ライブラリ更新済み

ここまでではネット上の記事を色々見回しましたがこれといって間違っていることは見当たりません。。
考えられるとしたら何があげられるでしょうか。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

tomato879241

2021/04/05 13:52

AppDelegateでなぜ「GoogleMobileAds」をimportするのでしょうか?AppDelegateの中でApplicationIDが設定されていないように見えるんですけど?
guest

回答1

0

自己解決

やはり、Adsnobの審査待ちだったようです。
審査には一日ほどかかるようで、無事待つだけで広告が表示されるようになりました。

投稿2021/04/05 22:22

komekome0101

総合スコア14

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問