Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most recent correct syntax to initialize the Google Mobile Ads SDK in the App Delegate file?

Tags:

xcode

swift4

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

like image 803
Derence Avatar asked Mar 24 '19 20:03

Derence


People also ask

How do I set up Google Mobile Ads?

Next to "Devices", click Edit. The section should expand and you'll be able to choose operating systems, device models, as well as carriers and Wi-Fi. Operating systems: Choose to show your ads to people on all operating systems or target specific ones. Example: Android or iOS.

How do I find my Google ads SDK on my phone?

Veer Arjun Busani(Mobile Ads SDK Team) The deprecation is only for Android Mobile Ads SDK and not for iOS. In any case, the easiest way to know your Mobile Ads SDK version would be to record a Charles session with your app and look at the request response. It would have your SDKs version number.

What is Mobile Ads SDK?

The Google Mobile Ads SDK for Ad Manager is a mobile advertising platform that you can use to generate revenue from your app.


1 Answers

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)
like image 112
Muhammad Shahid Avatar answered Sep 22 '22 19:09

Muhammad Shahid