LoginSignup
1
1

More than 5 years have passed since last update.

iOS Google AdMob Mobile SDKのアップデート対応

Posted at

Google Mobile Ads SDK をアップデート後、起動時に以下エラーが表示された場合

*** Terminating app due to uncaught exception 'GADInvalidInitializationException', reason: 'The Google Mobile Ads SDK was initialized incorrectly. Google AdMob publishers should follow instructions here: https://googlemobileadssdk.page.link/admob-ios-update-plist to include the AppMeasurement framework, set the -ObjC linker flag, and set GADApplicationIdentifier with a valid App ID. Google Ad Manager publishers should follow instructions here: https://googlemobileadssdk.page.link/ad-manager-ios-update-plist'

対応: info.plistにApp IDを記述する。

Google Mobile Ads SDK version 7.42.0より必須になったApp IDの記述が無いことに起因する。
* info.plistに以下の様にApp IDを追記する。

info.plist
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx</string>

初期化メソッドの変更

AppDelegate.swiftの application:DidFinishLaunchingWithOptions: メソッドで以下の処理がdeprecatedで警告されている。

GADMobileAds.configure(withApplicationID: "ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx")

このconfigureメソッドで行っているApp IDの設定は先ほどのinfo.plistに記述する方式に変わったので不要。この行は削除する。

また、これに替わり初期化するメソッドが定義されているので、こちらを同じくapplication:DidFinishLaunchingWithOptions: メソッドに記述する。

GADMobileAds.sharedInstance().start(completionHandler: nil)

参考

*AdMobのドキュメントに記載されていました。
スタートガイド  |  iOS  |  Google Developers

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1