19

All of a sudden, I get a warning on the code used to initialize the Google Mobile Ads SDK. (It had been working for weeks before with no warning, but now it seems there's a new way to write the code.)

This is the code I have:

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

But it gives me this warning: 'configure(withApplicationID:)' is deprecated: Use [GADMobileAds.sharedInstance startWithCompletionHandler:]

I've tried to rewrite it like this (with and without the square brackets):

GADMobileAds.sharedInstance startWithCompletionHandler: "ca-app-pub-################~##########"

But it just gives me an error that it expected a ;.

How should I write this? Thank you!

files from Pods folder in Xcode show a modified status

Derence
  • 408
  • 5
  • 18

2 Answers2

41

1) Add the follow in Info.plist

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>

2) in AppDelegate

 GADMobileAds.sharedInstance().start(completionHandler: nil)
Muhammad Shahid
  • 525
  • 5
  • 5
  • Thank you, sir! That seems to have worked. (I put in my own ca-app-pub- number of course :D) – Derence Mar 25 '19 at 21:31
  • do you know if we get consent before or after initializing SDK ? – isJulian00 Apr 06 '19 at 23:39
  • 1
    I'm not sure what that means, but I later did find the source of Muhammad's knowledge: https://developers.google.com/admob/ios/quick-start Maybe the answer is on that page @izzyMachado? – Derence Apr 08 '19 at 15:15
1

Thank you Sr, it worked for me on Xamarin, just I need it to make some little changes on the code as follow:

GADMobileAds.SharedInstance.Start(completionHandler: null)
Ramon Felix
  • 83
  • 1
  • 7